| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fzzy.igds.domain.FileInfo; |
| | | import com.fzzy.igds.domain.Quantity; |
| | | import com.fzzy.igds.mapper.FileMapper; |
| | | import com.fzzy.igds.utils.Base64Util; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | |
| | | private FileMapper fileMapper; |
| | | |
| | | /** |
| | | * 根据条件获取附件信息 |
| | | * @param companyId |
| | | * @param bizId |
| | | * @return |
| | | */ |
| | | public List<FileInfo> listFile(String companyId, String bizId) { |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(bizId)){ |
| | | return null; |
| | | } |
| | | |
| | | QueryWrapper<FileInfo> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("company_id", companyId); |
| | | queryWrapper.eq("biz_id", bizId); |
| | | queryWrapper.orderByAsc("create_time"); |
| | | |
| | | return fileMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 异步执行附件保存 |
| | | * @param files 附件信息 |
| | | * @param bizId 业务id |
| | |
| | | } |
| | | |
| | | data.setId(ContextUtil.generateId()); |
| | | data.setCreateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | |
| | | //文件全路径 |
| | | String filePath = getFileSavePath(pathTag) + data.getFileName(); |
| | | |
| | | filePath = filePath.replace(FrameworkConfig.getProfile(), "/profile/"); |
| | | data.setFilePath(filePath); |
| | | |
| | |
| | | data.setBizTag(bizTag); |
| | | } |
| | | |
| | | data.setCreateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | |
| | | data.setUpdateTime(new Date()); |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | fileMapper.insert(data); |
| | | saveFile(data); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param data |
| | | */ |
| | | public void saveFile(FileInfo data) { |
| | | |
| | | data.setUpdateTime(new Date()); |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | |
| | | if(StringUtils.isBlank(data.getId())){ |
| | | data.setId(ContextUtil.UUID()); |
| | | data.setCreateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | } |
| | | |
| | | fileMapper.insert(data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据条件查询数据 |
| | |
| | | if("TEMP".equals(pathTag)) return getTempFilePath(); |
| | | if("CONF".equals(pathTag)) return getConfPath(); |
| | | if("TEMPLATE".equals(pathTag)) return getTemplateFilePath(); |
| | | if("QUANTITY".equals(pathTag)) return getQuantityPath(); |
| | | if("WORD".equals(pathTag)) return getWordPath(); |
| | | |
| | | return getCommonFilePath(); |
| | |
| | | * 获取事件文件路径 |
| | | * @return |
| | | */ |
| | | public String getQuantityPath() { |
| | | String basePath = FrameworkConfig.getProfile() + "QUANTITY/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * 获取事件文件路径 |
| | | * @return |
| | | */ |
| | | public String getEventFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "EVENT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |