解决合并冲突

This commit is contained in:
s2042968 2024-11-21 16:49:53 +08:00
commit 1bc5ab6c4d
13 changed files with 601 additions and 114 deletions

View File

@ -5,12 +5,12 @@ import com.electromagnetic.industry.software.data.manage.request.indicator.EDDat
import electromagnetic.data.framework.share.model.ElectromagneticResult;
import electromagnetic.data.framework.share.model.ElectromagneticResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
@RequestMapping("/data/ed/file")
@RestController
@ -33,16 +33,29 @@ public class EDDataController {
}
@ApiOperation(value = "更新文件占用状态",notes = "")
@RequestMapping(value = "/updateFileStatus",method = RequestMethod.POST)
public ElectromagneticResult<?> updateFileStatus(@RequestBody EDDataRequest request){
return edDataFacade.updateFileStatus(request);
@ApiOperation(value = "更新文件信息",notes = "")
@RequestMapping(value = "/updateFileInfo",method = RequestMethod.POST)
public ElectromagneticResult<?> updateFileInfo(@RequestBody EDDataRequest request){
return edDataFacade.updateFileInfo(request);
}
@ApiOperation(value = "获取子文件数量",notes = "")
@RequestMapping(value = "/getChildFileCount",method = RequestMethod.POST)
public ElectromagneticResult<?> getChildFileCount(@RequestBody EDDataRequest request){
return edDataFacade.getChildFileCount(request);
}
@ApiOperation(value = "上传",notes = "")
@RequestMapping(value = "/upload",method = RequestMethod.POST)
public ElectromagneticResult<?> upload(@RequestBody EDDataRequest request){
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file,
@RequestParam("gmtBatchUpload") Long gmtBatchUpload){
EDDataRequest request = new EDDataRequest();
request.setParentId(parentId);
request.setFileData(file);
request.setGmtBatchUpload(new Date(gmtBatchUpload));
return edDataFacade.upload(request);
}
@ -61,10 +74,4 @@ public class EDDataController {
}
@ApiOperation(value = "重命名",notes = "")
@RequestMapping(value = "/rename",method = RequestMethod.POST)
public ElectromagneticResult<?> rename(@RequestBody EDDataRequest request){
return ElectromagneticResultUtil.success("重命名");
}
}

View File

@ -53,6 +53,22 @@ public class EDDataInfo {
* 状态publish:发布occupy:占用
*/
private String dataStatus;
/**
* 备注
*/
private String note;
/**
* 编辑人
*/
private String editor;
/**
* 批量上传时间
*/
private Date gmtBatchUpload;
/**
* 保存状态
*/
private String saveStatus;
/**
* 创建人
*/

View File

@ -1,8 +1,10 @@
package com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
import java.util.Date;
@Data
public class EDDataParams implements Serializable {
@ -18,21 +20,49 @@ public class EDDataParams implements Serializable {
/**
* 上级文件夹数据码,为空是顶级
*/
private Long parentId;
/**
* 文件夹名称
*/
private String name;
/**
* 关键词
*/
private String keyWord;
private String parentId;
/**
* 文件数据编码
*/
private String dataId;
/**
* 文件夹名称
*/
private String name;
/**
* 创建日期排序
*/
private String gmtCreate;
/**
* 文件数据状态
*/
private String dataStatus;
/**
* 备注
*/
private String note;
/**
* 是否有效
*/
private String effectFlag;
/**
* 关键词
*/
private String keyWord;
/**
* 批量上传时间
*/
private Date gmtBatchUpload;
/**
* 保存状态
*/
private String saveStatus;
/**
* 文件数据编码数组
*/
private String[] dataIdArr;
/**
* 文件数据
*/
private MultipartFile fileData;
}

View File

@ -7,6 +7,8 @@ import com.electromagnetic.industry.software.data.manage.domain.boardservice.ind
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* @author
* @version $Id: EDDataRepos.java, v 0.1 2024-07-29 19:02
@ -14,32 +16,32 @@ import com.github.pagehelper.PageInfo;
public interface EDDataRepository {
/**
* 创建文件
* 创建文件/文件数据信息
* @param edDataInfo
* @return
*/
Boolean createFolder(EDDataInfo edDataInfo);
Boolean createDataInfo(EDDataInfo edDataInfo);
/**
* 获取文件信息列表
* @param parames
* @return
*/
PageInfo<EDDataInfo> getDataInfoList(EDDataParams parames);
List<EDDataInfo> getDataInfoList(EDDataParams parames);
/**
* 更新文件占用状态
* 获取文件信息
* @param parames
* @return
*/
Boolean updateFileStatus(EDDataParams parames);
EDDataInfo getDataInfo(EDDataParams parames);
/**
* 上传
* 更新文件信息
* @param parames
* @return
*/
Boolean upload(EDDataParams parames);
Boolean updateFileInfo(EDDataParams parames);
/**
* 下载

View File

@ -7,11 +7,11 @@ import com.electromagnetic.industry.software.data.manage.domain.boardservice.ind
public interface EDDataService {
/**
* 创建文件
* 创建文件/文件数据信息
* @param edDataInfo
* @return
*/
Boolean createFolder(EDDataInfo edDataInfo);
Boolean createDataInfo(EDDataInfo edDataInfo);
/**
* 获取文件信息列表
@ -21,18 +21,25 @@ public interface EDDataService {
EDDataPage getDataInfoList(EDDataParams parames);
/**
* 更新文件占用状态
* 获取文件信息
* @param parames
* @return
*/
Boolean updateFileStatus(EDDataParams parames);
EDDataInfo getDataInfo(EDDataParams parames);
/**
* 上传
* 更新文件信息
* @param parames
* @return
*/
Boolean upload(EDDataParams parames);
Boolean updateFileInfo(EDDataParams parames);
/**
* 获取子文件数量
* @param parames
* @return
*/
Integer getChildFileCount(EDDataParams parames);
/**
* 下载
@ -41,4 +48,18 @@ public interface EDDataService {
*/
Boolean download(EDDataParams parames);
/**
* 检查文件夹是否存在
* @param path
* @return
*/
Boolean checkFolderIsExist(String path);
/**
* 创建多级目录
* @param path
* @return
*/
Boolean createMultiLevelDirectory(String path);
}

View File

@ -3,11 +3,13 @@
*/
package com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.service.impl;
import cn.hutool.poi.excel.cell.CellSetter;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataPage;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.repository.EDDataRepository;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.service.EDDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import electromagnetic.data.framework.share.exception.LoggerConstant;
import org.slf4j.Logger;
@ -15,6 +17,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/**
* @author
@ -30,13 +36,13 @@ public class EDDataServiceImpl implements EDDataService {
/**
* 创建文件
* 创建文件/文件数据信息
* @param edDataInfo
* @return
*/
public Boolean createFolder(EDDataInfo edDataInfo)
public Boolean createDataInfo(EDDataInfo edDataInfo)
{
edDataRepository.createFolder(edDataInfo);
edDataRepository.createDataInfo(edDataInfo);
return Boolean.TRUE;
}
@ -47,33 +53,59 @@ public class EDDataServiceImpl implements EDDataService {
*/
public EDDataPage getDataInfoList(EDDataParams parames)
{
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
List<EDDataInfo> edDataInfoList = edDataRepository.getDataInfoList(parames);
PageInfo<EDDataInfo> pageInfo = new PageInfo<>(edDataInfoList);
EDDataPage edDataPage=new EDDataPage();
//数据查询
PageInfo<EDDataInfo> pageInfo = edDataRepository.getDataInfoList(parames);
edDataPage.setEdDataInfo(pageInfo);
return edDataPage;
}
/**
* 更新文件占用状态
* 获取文件信息
* @param parames
* @return
*/
public Boolean updateFileStatus(EDDataParams parames)
public EDDataInfo getDataInfo(EDDataParams parames)
{
edDataRepository.updateFileStatus(parames);
return edDataRepository.getDataInfo(parames);
}
/**
* 更新文件信息
* @param parames
* @return
*/
public Boolean updateFileInfo(EDDataParams parames)
{
edDataRepository.updateFileInfo(parames);
return Boolean.TRUE;
}
/**
* 上传
* 获取子文件数量
* @param parames
* @return
*/
public Boolean upload(EDDataParams parames)
public Integer getChildFileCount(EDDataParams parames)
{
edDataRepository.upload(parames);
return Boolean.TRUE;
Integer childFileCount = 0;
List<EDDataInfo> edDataInfoList = edDataRepository.getDataInfoList(parames);
for (EDDataInfo edDataInfo : edDataInfoList) {
if(edDataInfo.getDataType().equals("folder"))
{
parames.setParentId(edDataInfo.getDataId());
childFileCount += getChildFileCount(parames);
}
else if(edDataInfo.getDataType().equals("file"))
{
++childFileCount;
}
}
return childFileCount;
}
/**
@ -87,6 +119,30 @@ public class EDDataServiceImpl implements EDDataService {
return Boolean.TRUE;
}
/**
* 检查文件夹是否存在
* @param path
* @return
*/
public Boolean checkFolderIsExist(String path)
{
return Files.exists(Paths.get(path));
}
/**
* 创建多级目录
* @param path
* @return
*/
public Boolean createMultiLevelDirectory(String path)
{
try {
Files.createDirectories(Paths.get(path));
return Boolean.TRUE;
} catch (IOException e) {
return Boolean.FALSE;
}
}
}

View File

@ -18,6 +18,10 @@
<groupId>com.electromagnetic.data</groupId>
<artifactId>electromagnetic-framework</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
</dependencies>

View File

@ -4,6 +4,9 @@ import com.electromagnetic.industry.software.data.manage.request.indicator.EDDat
import com.electromagnetic.industry.software.data.manage.response.indicator.EDDataPageResponse;
import electromagnetic.data.framework.share.model.ElectromagneticResult;
import java.util.List;
import java.util.Map;
public interface EDDataFacade {
/**
@ -22,11 +25,18 @@ public interface EDDataFacade {
ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request);
/**
* 更新文件占用状态
* 更新文件信息
* @param request
* @return
*/
ElectromagneticResult<Boolean> updateFileStatus(EDDataRequest request);
ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request);
/**
* 获取子文件数量
* @param request
* @return
*/
ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request);
/**
* 上传
@ -40,6 +50,20 @@ public interface EDDataFacade {
* @param request
* @return
*/
ElectromagneticResult<Boolean> download(EDDataRequest request);
ElectromagneticResult<Map<String, List<String>>> download(EDDataRequest request);
/**
* 导出
* @param request
* @return
*/
ElectromagneticResult<String> batchExport(EDDataRequest request);
/**
* 导入
* @param request
* @return
*/
ElectromagneticResult<String> batchImport(EDDataRequest request);
}

View File

@ -1,8 +1,11 @@
package com.electromagnetic.industry.software.data.manage.request.indicator;
import org.springframework.web.multipart.MultipartFile;
import electromagnetic.data.framework.share.model.BaseRequest;
import lombok.Data;
import java.util.Date;
@Data
public class EDDataRequest extends BaseRequest {
@ -17,21 +20,49 @@ public class EDDataRequest extends BaseRequest {
/**
* 上级文件夹数据码,为空是顶级
*/
private Long parentId;
/**
* 文件夹名称
*/
private String name;
/**
* 关键词
*/
private String keyWord;
private String parentId;
/**
* 文件数据编码
*/
private String dataId;
/**
* 文件夹名称
*/
private String name;
/**
* 创建日期排序
*/
private String gmtCreate;
/**
* 文件数据状态
*/
private String dataStatus;
/**
* 备注
*/
private String note;
/**
* 是否有效
*/
private String effectFlag;
/**
* 关键词
*/
private String keyWord;
/**
* 批量上传时间
*/
private Date gmtBatchUpload;
/**
* 保存状态
*/
private String saveStatus;
/**
* 文件数据编码数组
*/
private String[] dataIdArr;
/**
* 文件数据
*/
private MultipartFile fileData;
}

View File

@ -2,6 +2,8 @@ package com.electromagnetic.industry.software.data.manage.repository.dao;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
import com.electromagnetic.industry.software.data.manage.request.indicator.EDDataRequest;
import electromagnetic.data.framework.share.model.ElectromagneticResult;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -24,11 +26,10 @@ public interface EDDataMapper {
List<EDDataInfo> getDataInfoList(EDDataParams parames);
/**
* 更新文件占用状态
* 更新文件信息
* @param parames
* @return
*/
Boolean updateFileStatus(EDDataParams parames);
Boolean updateFileInfo(EDDataParams parames);
}

View File

@ -25,13 +25,13 @@ public class EDDataRepositoryImpl implements EDDataRepository {
private EDDataMapper edDataMapper;
/**
* 创建文件
* 创建文件/文件数据信息
*
* @param edDataInfo
* @return
*/
@Override
public Boolean createFolder(EDDataInfo edDataInfo)
public Boolean createDataInfo(EDDataInfo edDataInfo)
{
return edDataMapper.createDataInfo(edDataInfo);
}
@ -42,35 +42,35 @@ public class EDDataRepositoryImpl implements EDDataRepository {
* @return
*/
@Override
public PageInfo<EDDataInfo> getDataInfoList(EDDataParams parames)
public List<EDDataInfo> getDataInfoList(EDDataParams parames)
{
return edDataMapper.getDataInfoList(parames);
}
/**
* 获取文件信息
* @param parames
* @return
*/
@Override
public EDDataInfo getDataInfo(EDDataParams parames)
{
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
List<EDDataInfo> edDataInfoList=edDataMapper.getDataInfoList(parames);
return new PageInfo<>(edDataInfoList);
if(edDataInfoList.size()>0)
return edDataInfoList.get(0);
else
return null;
}
/**
* 更新文件占用状态
* 更新文件信息
* @param parames
* @return
*/
@Override
public Boolean updateFileStatus(EDDataParams parames)
public Boolean updateFileInfo(EDDataParams parames)
{
return edDataMapper.updateFileStatus(parames);
}
/**
* 上传
* @param parames
* @return
*/
@Override
public Boolean upload(EDDataParams parames)
{
//return edDataMapper.upload(parames);
//edDataMapper.createDataInfo(edDataInfo);
return Boolean.TRUE;
return edDataMapper.updateFileInfo(parames);
}
/**
@ -86,4 +86,5 @@ public class EDDataRepositoryImpl implements EDDataRepository {
}
}

View File

@ -14,6 +14,10 @@
<result column="content" jdbcType="VARCHAR" property="content" />
<result column="implant_json" jdbcType="VARCHAR" property="implantJson" />
<result column="data_status" jdbcType="VARCHAR" property="dataStatus" />
<result column="note" jdbcType="VARCHAR" property="note" />
<result column="editor" jdbcType="VARCHAR" property="editor" />
<result column="gmt_batch_upload" jdbcType="TIMESTAMP" property="gmtBatchUpload" />
<result column="save_status" jdbcType="VARCHAR" property="saveStatus" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
@ -24,7 +28,7 @@
</resultMap>
<sql id="Base_Column_list">
id,category_id,data_id,data_no,data_name,data_type,file_type,version,content,
implant_json,data_status,creator,creator_name,gmt_create,modifier,modifier_name,
implant_json,data_status,note,editor,gmt_batch_upload,save_status,creator,creator_name,gmt_create,modifier,modifier_name,
gmt_modified,effect_flag
</sql>
@ -35,16 +39,18 @@
</selectKey>
insert into ed_data_info (id, category_id,
data_id, data_no, data_name,
data_type, file_type,
version,content, implant_json, data_status,
data_type, file_type, version,
content, implant_json, data_status,
note, editor, gmt_batch_upload, save_status,
creator, creator_name, gmt_create,
modifier, modifier_name, gmt_modified,
effect_flag
)
values (#{id,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},
#{version,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP}, #{saveStatus,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR},now(),1
)
@ -61,23 +67,45 @@
<if test="parentId!=null and parentId!=''">
and category_id='${parentId}'
</if>
<if test="dataId!=null and dataId!=''">
and data_id='${dataId}'
</if>
<if test="keyWord!=null and keyWord!=''">
and data_name LIKE '%${keyWord}%'
</if>
<if test="saveStatus!=null and saveStatus!=''">
and save_status='${saveStatus}'
</if>
GROUP BY id
order by gmt_modified asc
<if test="gmtCreate == 'asc' or gmtCreate =='desc'">
order by gmt_create ${gmtCreate}
</if>
</select>
<update id="updateFileStatus" parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams">
<update id="updateFileInfo" parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams">
update ed_data_info
<set>
<if test="name != null and name!=''">
data_name = #{name,jdbcType=VARCHAR},
</if>
<if test="dataStatus != null and dataStatus!=''">
data_status = #{dataStatus,jdbcType=VARCHAR},
</if>
<if test="note != null and note!=''">
note = #{note,jdbcType=VARCHAR},
</if>
<if test="saveStatus != null and note!=''">
save_status = #{saveStatus,jdbcType=VARCHAR},
</if>
<if test="effectFlag != null and effectFlag!=''">
effect_flag = #{effectFlag,jdbcType=VARCHAR},
</if>
gmt_modified = now()
</set>
where data_id = #{dataId,jdbcType=VARCHAR} and effect_flag = 1
</update>
</mapper>

View File

@ -1,5 +1,7 @@
package com.electromagnetic.industry.software.data.manage.service.facade;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataPage;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
@ -11,9 +13,16 @@ import com.electromagnetic.industry.software.data.manage.service.mappers.EDDataM
import electromagnetic.data.framework.share.id.IdWorker;
import electromagnetic.data.framework.share.model.ElectromagneticResult;
import electromagnetic.data.framework.share.model.ElectromagneticResultUtil;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
@Service
public class EDDataFacadeImpl implements EDDataFacade {
@ -32,21 +41,73 @@ public class EDDataFacadeImpl implements EDDataFacade {
@Override
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
EDDataInfo edDataInfo = EDDataMappers.INSTANCE.getEDDataInfo(request);
edDataInfo.setCreator(request.getUserId());
edDataInfo.setCreatorName(request.getPersonName());
//edDataInfo.setModifier(request.getUserId());
edDataInfo.setModifierName(request.getPersonName());
edDataInfo.setModifier(IdWorker.getSnowFlakeIdString());
edDataInfo.setCategoryId(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataNo(IdWorker.getSnowFlakeIdString());
// 临时数据设置
if(Boolean.TRUE) {
if (request.getUserId() == null || request.getUserId().isEmpty()) request.setUserId(IdWorker.getSnowFlakeIdString());
if (request.getUserName() == null || request.getUserName().isEmpty()) request.setUserName("user");
if (request.getName() == null || request.getName().isEmpty()) request.setName("testFolder");
//if (request.getParentId() == null || request.getParentId().isEmpty()) request.setParentId(IdWorker.getSnowFlakeIdString());
}
edDataInfo.setCreator(request.getUserId());
edDataInfo.setCreatorName(request.getUserName());
edDataInfo.setModifier(request.getUserId());
edDataInfo.setModifierName(request.getUserName());
edDataInfo.setCategoryId(request.getParentId());
edDataInfo.setDataName(request.getName());
edDataInfo.setNote(request.getNote());
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataNo(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataType("folder");
edDataInfo.setDataName("testFolder");
edDataInfo.setVersion("1.0.0");
edDataInfo.setDataStatus("publish");
edDataService.createFolder(edDataInfo);
String parentFolderPath = "";
// 获取上级目录的名称
if(!request.getParentId().isEmpty()) {
EDDataParams parames = new EDDataParams();
parames.setDataId(request.getParentId());
EDDataInfo edDataInfoParent = edDataService.getDataInfo(parames);
if(edDataInfoParent == null) {
ElectromagneticResultUtil.fail(HttpStatus.BAD_REQUEST.toString(),"上级文件夹为空!");
}
String folderNameParent = edDataInfoParent.getDataName();
String folderIdParent = edDataInfoParent.getDataId();
// 记录当前目录的文件夹路径和文件夹id路径
JSONObject implantJsonObject = JSON.parseObject(edDataInfoParent.getImplantJson());
if(implantJsonObject == null) {
implantJsonObject = new JSONObject();
parentFolderPath = folderNameParent;
implantJsonObject.put("folderPath", parentFolderPath);
implantJsonObject.put("folderIdPath", folderIdParent);
}
else
{
String folderPath = implantJsonObject.getString("folderPath");
String folderIdPath = implantJsonObject.getString("folderIdPath");
parentFolderPath = folderPath + "/" + folderNameParent;
implantJsonObject.put("folderPath", parentFolderPath);
implantJsonObject.put("folderIdPath", folderIdPath + "/" + folderIdParent);
}
String newImplantJson = implantJsonObject.toJSONString();
edDataInfo.setImplantJson(newImplantJson);
}
boolean isSuccess = edDataService.createDataInfo(edDataInfo);
if(isSuccess)
{
// 获取文件存储的文件夹路径
String storageDirectory = "D:/fileTemp/" + parentFolderPath + "/" + edDataInfo.getDataName();
if(!edDataService.checkFolderIsExist(storageDirectory)) {
edDataService.createMultiLevelDirectory(storageDirectory);
}
}
return ElectromagneticResultUtil.success(Boolean.TRUE);
}
@ -61,6 +122,7 @@ public class EDDataFacadeImpl implements EDDataFacade {
*/
public ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
//获取中支指标配置列表
EDDataPage edDataPage = edDataService.getDataInfoList(parames);
@ -70,19 +132,35 @@ public class EDDataFacadeImpl implements EDDataFacade {
}
/**
* 更新文件占用状态
* WISDOM_UPDATE_FILESTATUS
* /data/ed/file/updateFileStatus
* 更新文件信息
* WISDOM_UPDATE_FILEINFO
* /data/ed/file/updateFileInfo
* @param request
* @return
*/
public ElectromagneticResult<Boolean> updateFileStatus(EDDataRequest request)
public ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
edDataService.updateFileStatus(parames);
edDataService.updateFileInfo(parames);
return ElectromagneticResultUtil.success(Boolean.TRUE);
}
/**
* 获取子文件数量
* WISDOM_GET_CHILDFILECOUNT
* /data/ed/file/getChildFileCount
* @param request
* @return
*/
public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
Integer fileCount = edDataService.getChildFileCount(parames);
Map<String, Integer> result = new HashMap<>();
result.put("fileCount", fileCount);
return ElectromagneticResultUtil.success(result);
}
/**
* 上传
* WISDOM_UPLOAD
@ -93,8 +171,146 @@ public class EDDataFacadeImpl implements EDDataFacade {
public ElectromagneticResult<Boolean> upload(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
edDataService.upload(parames);
return ElectromagneticResultUtil.success(Boolean.TRUE);
try {
// 获取目录编码ID
String categoryId = request.getParentId();
// 获取要上传的文件
MultipartFile fileInput = request.getFileData();
// 检查文件是否为空
if (fileInput == null || fileInput.isEmpty()) {
return ElectromagneticResultUtil.fail(HttpStatus.BAD_REQUEST.toString(),"上传的文件为空");
}
// 获取文件名
String fileFullName = fileInput.getOriginalFilename();
// 获取文件类型
String fileType = "";
// 获取文件名称
String fileName = "";
if (fileFullName.lastIndexOf(".") != -1 && fileFullName.lastIndexOf(".") != 0) {
fileType = fileFullName.substring(fileFullName.lastIndexOf(".") + 1);
fileName = fileFullName.substring(fileFullName.lastIndexOf("."));
}
// 获取文件存储的文件夹路径
String storageDirectory = "D:/fileTemp";
if(!edDataService.checkFolderIsExist(storageDirectory)) {
edDataService.createMultiLevelDirectory(storageDirectory);
}
String parentFolderPath = ""; //上级文件夹路径
String parentFolderIdPath = ""; //上级文件夹ID路径
String parentFolderName = ""; //上级文件夹名称
// 获取上级文件夹路径
{
EDDataParams folderParames = new EDDataParams();
folderParames.setDataId(categoryId);
EDDataInfo edDataInfoParent = edDataService.getDataInfo(folderParames);
if(edDataInfoParent == null) {
ElectromagneticResultUtil.fail(HttpStatus.BAD_REQUEST.toString(),"上级文件夹为空!");
}
JSONObject implantJsonObject = JSON.parseObject(edDataInfoParent.getImplantJson());
parentFolderPath = implantJsonObject.getString("folderPath");
parentFolderIdPath = implantJsonObject.getString("folderIdPath");
if(!parentFolderPath.isEmpty())
parentFolderPath += "/" ;
if(!parentFolderIdPath.isEmpty())
parentFolderIdPath += "/" ;
parentFolderPath += edDataInfoParent.getDataName();
parentFolderIdPath += edDataInfoParent.getDataId();
parentFolderName = edDataInfoParent.getDataName();
}
// 文件保存目录路径
String fileSavePath = storageDirectory + "/" + parentFolderPath;
String treeName = "目录树名称";
String newFileName = treeName + "," + parentFolderName + "," + fileFullName;
// 文件数据信息写到数据库
{
// 临时数据设置
if(Boolean.TRUE) {
if (request.getUserId() == null || request.getUserId().isEmpty()) request.setUserId(IdWorker.getSnowFlakeIdString());
if (request.getUserName() == null || request.getUserName().isEmpty()) request.setUserName("user");
//if (request.getName() == null || request.getName().isEmpty()) request.setName("testFolder");
if (request.getParentId() == null || request.getParentId().isEmpty()) request.setParentId(IdWorker.getSnowFlakeIdString());
}
// 创建新文件数据
EDDataInfo edDataInfo = new EDDataInfo();
edDataInfo.setCreator(request.getUserId());
edDataInfo.setCreatorName(request.getUserName());
edDataInfo.setModifier(request.getUserId());
edDataInfo.setModifierName(request.getUserName());
edDataInfo.setCategoryId(request.getParentId());
edDataInfo.setDataName(newFileName);
edDataInfo.setNote(request.getNote());
edDataInfo.setFileType(fileType);
edDataInfo.setGmtBatchUpload(request.getGmtBatchUpload());
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataNo(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataType("file");
edDataInfo.setVersion("1.0.0");
edDataInfo.setDataStatus("publish");
edDataInfo.setSaveStatus("saving");
JSONObject newImplantJsonObject = new JSONObject();
newImplantJsonObject.put("folderPath", parentFolderPath);
newImplantJsonObject.put("folderIdPath", parentFolderIdPath);
edDataInfo.setImplantJson(newImplantJsonObject.toJSONString());
boolean isSuccess = edDataService.createDataInfo(edDataInfo);
String userHome = System.getProperty("user.home");
File cacheDirectory = new File(userHome + "\\AppData\\Local\\Temp\\EDData");
if (!cacheDirectory.exists()) {
cacheDirectory.mkdirs();
}
String cacheFolder = cacheDirectory.getAbsolutePath();
String cachePath = cacheFolder + "/" + newFileName;
System.out.println("文件缓存路径为: " + cacheDirectory.getAbsolutePath());
fileSavePath += "/" + newFileName;
// 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑
File saveFile = new File(cachePath);//fileSavePath
// 将文件保存到硬盘
fileInput.transferTo(saveFile);
EDDataParams fileParames = new EDDataParams();
fileParames.setDataId(edDataInfo.getDataId());
if(fileInput.getSize() == saveFile.length())
{
Path source = Paths.get(cachePath);
Path target = Paths.get(fileSavePath);
Files.move(source, target);
fileParames.setSaveStatus("success");
}
else
{
saveFile.delete();
fileParames.setSaveStatus("failure");
}
isSuccess = edDataService.updateFileInfo(fileParames);
}
// 如果文件上传成功返回成功消息
return ElectromagneticResultUtil.success(Boolean.TRUE);
} catch (Exception e) {
// 如果出现异常返回异常消息
return ElectromagneticResultUtil.fail(HttpStatus.INTERNAL_SERVER_ERROR.toString(),"文件上传失败" + e.getMessage());
}
}
/**
@ -104,13 +320,63 @@ public class EDDataFacadeImpl implements EDDataFacade {
* @param request
* @return
*/
public ElectromagneticResult<Boolean> download(EDDataRequest request)
public ElectromagneticResult<Map<String, List<String>>> download(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
edDataService.download(parames);
return ElectromagneticResultUtil.success(Boolean.TRUE);
//EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
// 获取文件存储的文件夹路径
String storageDirectory = "D:/fileTemp";
EDDataParams parames = new EDDataParams();
List<String> dataPathArr = new ArrayList();
for(String dataId : request.getDataIdArr())
{
parames.setDataId(dataId);
EDDataInfo edDataInfo = edDataService.getDataInfo(parames);
if(edDataInfo != null)
{
JSONObject implantJsonObject = JSON.parseObject(edDataInfo.getImplantJson());
String filePath = implantJsonObject.getString("folderPath");
filePath = storageDirectory + "/" + filePath + "/" + edDataInfo.getDataName();
dataPathArr.add(filePath);
}
}
Map<String, List<String>> result = new HashMap<>();
result.put("urlArr", dataPathArr);
return ElectromagneticResultUtil.success(result);
}
/**
* 导出
* @param request
* @return
*/
@Override
public ElectromagneticResult<String> batchExport(EDDataRequest request) {
//1根据用户选择层级树编码查出所有文件和文件夹list
//2循环list将每个文件复制到新建目录并进行重命名命名规则目录树编码+,+文件夹编码有则填写无则为空+,+文件编码
//3打包新建为zip并根据生产下载地址域名+文件路径+文件
//4返回前端下载的地址
return null;
}
/**
* 导入
* @param request
* @return
*/
@Override
public ElectromagneticResult<String> batchImport(EDDataRequest request) {
//1上传文件到指定目录并重命名
//2接下压缩包
//3扫码解压文件夹的所有文件
//4循环处理文件读取文件名称根据名称规则进行数据库查询匹配层级树文件夹和文件是否跳过
//5如果不存在则新建文件记录
//6并移动文件到上传目录
//7处理完成返回成功
return null;
}
}