三江-安全环保资料中心接口修改
This commit is contained in:
parent
a615c2b0d5
commit
bc4ef1c981
@ -54,5 +54,7 @@ public class UploadFileDTO {
|
||||
private long currentChunkSize;
|
||||
@ApiModelProperty(value = "md5码")
|
||||
private String identifier;
|
||||
@ApiModelProperty(value = "项目SN或企业sn")
|
||||
private String sn;
|
||||
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.quality.entity.QualityRectifyRecord;
|
||||
import com.zhgd.xmgl.modules.quality.entity.vo.DepartmentRectifiedRankVo;
|
||||
import com.zhgd.xmgl.modules.quality.service.IQualityRectifyRecordService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -19,50 +18,52 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @Title: Controller
|
||||
* @Description: 质量检查-整改记录
|
||||
* @author: pds
|
||||
* @date: 2021-06-17
|
||||
* @date: 2021-06-17
|
||||
* @version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/qualityRectifyRecord")
|
||||
@Slf4j
|
||||
@Api(tags="质量检查-整改记录")
|
||||
@Api(tags = "质量检查-整改记录")
|
||||
public class QualityRectifyRecordController {
|
||||
@Autowired
|
||||
private IQualityRectifyRecordService qualityRectifyRecordService;
|
||||
@Autowired
|
||||
private IQualityRectifyRecordService qualityRectifyRecordService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询质量检查-整改/复查记录信息", notes = "列表查询质量检查-整改/复查记录信息", httpMethod="POST")
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询质量检查-整改/复查记录信息", notes = "列表查询质量检查-整改/复查记录信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "qualityId", value = "质量检查记录ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@PostMapping(value = "/selectRectifyRecordList")
|
||||
public Result<List<EntityMap>> selectRectifyRecordList(@RequestBody Map<String,Object> map) {
|
||||
return Result.success(qualityRectifyRecordService.selectRectifyRecordList(map));
|
||||
}
|
||||
public Result<List<EntityMap>> selectRectifyRecordList(@RequestBody Map<String, Object> map) {
|
||||
return Result.success(qualityRectifyRecordService.selectRectifyRecordList(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param qualityRectifyRecord
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "质量管理", operType = "添加质量检查整改/复查记录信息", operDesc = "添加质量检查整改/复查记录信息")
|
||||
@ApiOperation(value = " 添加质量检查-整改/复查记录信息", notes = "添加质量检查-整改/复查记录信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<QualityRectifyRecord> add(@RequestBody QualityRectifyRecord qualityRectifyRecord) {
|
||||
qualityRectifyRecordService.saveQualityRectifyRecord(qualityRectifyRecord);
|
||||
return Result.ok();
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param qualityRectifyRecord
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "质量管理", operType = "添加质量检查整改/复查记录信息", operDesc = "添加质量检查整改/复查记录信息")
|
||||
@ApiOperation(value = " 添加质量检查-整改/复查记录信息", notes = "添加质量检查-整改/复查记录信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<QualityRectifyRecord> add(@RequestBody QualityRectifyRecord qualityRectifyRecord) {
|
||||
qualityRectifyRecordService.saveQualityRectifyRecord(qualityRectifyRecord);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出质量问题和整改记录excel", notes = "导出质量问题和整改记录excel", httpMethod = "POST")
|
||||
@PostMapping(value = "/recordRectify/excel/export")
|
||||
public void qualityInspectionRecordRectifyExportExcel(@RequestBody Map<String, Object> map, HttpServletResponse response) throws IOException {
|
||||
qualityRectifyRecordService.qualityInspectionRecordRectifyExportExcel(map, response);
|
||||
}
|
||||
@ApiOperation(value = "导出质量问题和整改记录excel", notes = "导出质量问题和整改记录excel", httpMethod = "GET")
|
||||
@GetMapping(value = "/recordRectify/excel/export")
|
||||
public void qualityInspectionRecordRectifyExportExcel(@RequestParam(required = false) Map<String, Object> map, HttpServletResponse response) throws IOException {
|
||||
qualityRectifyRecordService.qualityInspectionRecordRectifyExportExcel(map, response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class QualityInspectionRecordServiceImpl extends ServiceImpl<QualityInspe
|
||||
List<Long> regionIds = JSON.parseObject(map.get("regionId").toString(), new TypeReference<List<Long>>() {
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(regionIds)) {
|
||||
Long topId = regionIds.get(0);
|
||||
Long topId = regionIds.get(regionIds.size() - 1);
|
||||
List<QualityRegion> qualityRegionList = qualityRegionMapper.selectList(new LambdaQueryWrapper<QualityRegion>().eq(QualityRegion::getProjectSn, MapUtils.getString(map, "projectSn")));
|
||||
List<Long> idList = getChildrenByQualityRegionId(topId, qualityRegionList);
|
||||
idList.add(topId);
|
||||
|
||||
@ -109,7 +109,7 @@ public class QualityRectifyRecordServiceImpl extends ServiceImpl<QualityRectifyR
|
||||
TemplateExportParams params = new TemplateExportParams(path);
|
||||
Map<String, Object> rtMap = new HashMap<String, Object>();
|
||||
rtMap.put("createTime", DateUtil.format(new Date(), "yyyy年MM月dd日"));
|
||||
rtMap.put("list", getRecordMapList(map, rtMap));
|
||||
rtMap.put("list", getRecordMapList(map));
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(params, rtMap);
|
||||
|
||||
//准备将Excel的输出流通过response输出到页面下载
|
||||
@ -126,7 +126,7 @@ public class QualityRectifyRecordServiceImpl extends ServiceImpl<QualityRectifyR
|
||||
workbook.write(response.getOutputStream());
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getRecordMapList(Map<String, Object> map, Map<String, Object> rtMap) {
|
||||
private List<Map<String, Object>> getRecordMapList(Map<String, Object> map) {
|
||||
map.put("pageSize", Integer.MAX_VALUE);
|
||||
Map<String, Object> recordPage = qualityInspectionRecordService.selectQualityInspectionRecordPage(map);
|
||||
Page page = (Page) recordPage.get("page");
|
||||
|
||||
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.base.TreeNode;
|
||||
import com.zhgd.xmgl.base.UploadFileDTO;
|
||||
import com.zhgd.xmgl.base.UploadFileVo;
|
||||
import com.zhgd.xmgl.modules.sanjiang.entity.SjSafeEnvironmentFile;
|
||||
import com.zhgd.xmgl.modules.sanjiang.service.ISjSafeEnvironmentFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -15,6 +17,7 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@ -28,32 +31,44 @@ import java.util.*;
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/sjSafeEnvironmentFile")
|
||||
@Slf4j
|
||||
@Api("ProjectFileController相关Api")
|
||||
@Api("三江安全环保资料中心")
|
||||
public class SjSafeEnvironmentFileController {
|
||||
@Autowired
|
||||
private ISjSafeEnvironmentFileService sjSafeEnvironmentFileService;
|
||||
@Autowired
|
||||
private ISjSafeEnvironmentFileService sjSafeEnvironmentFileService;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 分块上传文件
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分块上传文件", notes = "分块上传文件", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "sn", value = "项目SN或企业sn", paramType = "query", required = true, dataType = "String")
|
||||
})
|
||||
@RequestMapping(value = "/uploadfile", method = RequestMethod.POST)
|
||||
public Result<UploadFileVo> uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto) {
|
||||
return sjSafeEnvironmentFileService.uploadFile(request, uploadFileDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询项目文件档案信息", notes = "列表查询项目文件档案信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "sn", value = "项目SN或企业sn", paramType = "query", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "filePath", value = "路径", paramType = "query", required = true, dataType = "Integer"),
|
||||
})
|
||||
@PostMapping(value = "/list")
|
||||
public Result<List<SjSafeEnvironmentFile>> getFileList(@RequestBody Map<String, Object> map) {
|
||||
QueryWrapper<SjSafeEnvironmentFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SjSafeEnvironmentFile::getProjectSn, MapUtils.getString(map, "projectSn"))
|
||||
.eq(SjSafeEnvironmentFile::getFilePath, MapUtils.getString(map, "filePath"));
|
||||
queryWrapper.orderByAsc("is_dir");
|
||||
List<SjSafeEnvironmentFile> list = sjSafeEnvironmentFileService.list(queryWrapper);
|
||||
return Result.success(list);
|
||||
return sjSafeEnvironmentFileService.getFileList(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* 添加
|
||||
*
|
||||
* @param sjSafeEnvironmentFile
|
||||
* @return
|
||||
*/
|
||||
@ -76,8 +91,7 @@ public class SjSafeEnvironmentFileController {
|
||||
@ApiOperation(value = "文件重命名", notes = "文件重命名", httpMethod = "POST")
|
||||
@PostMapping(value = "/renameFile")
|
||||
public Result<SjSafeEnvironmentFile> edit(@RequestBody SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
sjSafeEnvironmentFileService.renamefile(sjSafeEnvironmentFile);
|
||||
return Result.ok();
|
||||
return sjSafeEnvironmentFileService.renamefile(sjSafeEnvironmentFile);
|
||||
}
|
||||
|
||||
|
||||
@ -93,16 +107,14 @@ public class SjSafeEnvironmentFileController {
|
||||
@ApiOperation(value = "删除文件", notes = "可以删除文件或者目录", httpMethod = "POST")
|
||||
@RequestMapping(value = "/deleteFile", method = RequestMethod.POST)
|
||||
public Result<String> deleteFile(@RequestBody SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
sjSafeEnvironmentFileService.deleteFile(sjSafeEnvironmentFile);
|
||||
return Result.ok();
|
||||
return sjSafeEnvironmentFileService.deleteFile(sjSafeEnvironmentFile);
|
||||
}
|
||||
|
||||
@OperLog(operModul = "项目文件管理", operType = "文件移动", operDesc = "文件移动")
|
||||
@ApiOperation(value = "文件移动", notes = "可以移动文件或者目录", httpMethod = "POST")
|
||||
@RequestMapping(value = "/moveFile", method = RequestMethod.POST)
|
||||
public Result<String> moveFile(@RequestBody SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
sjSafeEnvironmentFileService.moveFile(sjSafeEnvironmentFile);
|
||||
return Result.ok();
|
||||
public Result moveFile(@RequestBody SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
return sjSafeEnvironmentFileService.moveFile(sjSafeEnvironmentFile);
|
||||
}
|
||||
|
||||
@OperLog(operModul = "项目文件管理", operType = "批量文件移动", operDesc = "批量文件移动")
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
package com.zhgd.xmgl.modules.sanjiang.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 三江安全环保资料中心
|
||||
@ -74,4 +76,9 @@ public class SjSafeEnvironmentFile implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "文件大小")
|
||||
private java.lang.String fileSize;
|
||||
|
||||
@ApiModelProperty(value = "项目SN或企业sn")
|
||||
@TableField(exist = false)
|
||||
private java.lang.String sn;
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package com.zhgd.xmgl.modules.sanjiang.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhgd.xmgl.modules.sanjiang.entity.SjSafeEnvironmentFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 三江安全环保资料中心
|
||||
@ -16,7 +18,11 @@ public interface SjSafeEnvironmentFileMapper extends BaseMapper<SjSafeEnvironmen
|
||||
|
||||
void replaceProjectFilePath(@Param("filePath") String filePath, @Param("oldFilePath") String oldFilePath, @Param("projectSn") String projectSn);
|
||||
|
||||
void replaceProjectFilePathAndProjectSnList(@Param("filePath") String filePath, @Param("oldFilePath") String oldFilePath, @Param("list") List<String> projectSnList);
|
||||
|
||||
void updateFilepathByFilepath(@Param("oldfilePath") String oldfilePath, @Param("newfilePath") String newfilePath, @Param("projectSn") String projectSn);
|
||||
|
||||
void updateFilepathByFilepathAndProjectSnList(@Param("oldfilePath") String oldfilePath, @Param("newfilePath") String newfilePath, @Param("list") List<String> projectSnList);
|
||||
|
||||
void updateFilepathByPathAndName(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
}
|
||||
|
||||
@ -6,10 +6,29 @@
|
||||
WHERE file_path LIKE N'${oldFilePath}%' and project_sn = #{projectSn};
|
||||
</update>
|
||||
|
||||
<update id="replaceProjectFilePathAndProjectSnList">
|
||||
UPDATE sj_safe_environment_file SET file_path=REPLACE(file_path, #{oldFilePath}, #{filePath})
|
||||
WHERE file_path LIKE N'${oldFilePath}%' and
|
||||
project_sn in
|
||||
<foreach collection="list" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateFilepathByFilepath">
|
||||
UPDATE sj_safe_environment_file SET file_path=REPLACE(file_path, #{oldfilePath}, #{newfilePath})
|
||||
WHERE file_path like N'${oldfilePath}%' and project_sn = #{projectSn};
|
||||
</update>
|
||||
<update id="updateFilepathByFilepathAndProjectSnList">
|
||||
UPDATE sj_safe_environment_file SET file_path=REPLACE(file_path, #{oldfilePath}, #{newfilePath})
|
||||
WHERE file_path like N'${oldfilePath}%' and
|
||||
project_sn in
|
||||
<foreach collection="list" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateFilepathByPathAndName">
|
||||
UPDATE sj_safe_environment_file SET file_path=#{filePath}
|
||||
WHERE file_id=#{fileId}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
package com.zhgd.xmgl.modules.sanjiang.service;
|
||||
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.base.UploadFileDTO;
|
||||
import com.zhgd.xmgl.base.UploadFileVo;
|
||||
import com.zhgd.xmgl.modules.sanjiang.entity.SjSafeEnvironmentFile;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 项目文件档案
|
||||
@ -15,11 +20,15 @@ public interface ISjSafeEnvironmentFileService extends IService<SjSafeEnvironmen
|
||||
|
||||
void addProjectFile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
|
||||
void renamefile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
Result<SjSafeEnvironmentFile> renamefile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
|
||||
void batchDeleteFile(List<SjSafeEnvironmentFile> list);
|
||||
|
||||
void deleteFile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
Result<String> deleteFile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
|
||||
void moveFile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
Result<String> moveFile(SjSafeEnvironmentFile sjSafeEnvironmentFile);
|
||||
|
||||
Result<UploadFileVo> uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto);
|
||||
|
||||
Result<List<SjSafeEnvironmentFile>> getFileList(Map<String, Object> map);
|
||||
}
|
||||
|
||||
@ -1,19 +1,34 @@
|
||||
package com.zhgd.xmgl.modules.sanjiang.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.jeecg.upload.Uploader;
|
||||
import com.zhgd.jeecg.upload.domain.UploadFile;
|
||||
import com.zhgd.jeecg.upload.factory.ChunkUploaderFactory;
|
||||
import com.zhgd.jeecg.upload.util.DateUtil;
|
||||
import com.zhgd.xmgl.base.UploadFileDTO;
|
||||
import com.zhgd.xmgl.base.UploadFileVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.sanjiang.entity.SjSafeEnvironmentFile;
|
||||
import com.zhgd.xmgl.modules.sanjiang.mapper.SjSafeEnvironmentFileMapper;
|
||||
import com.zhgd.xmgl.modules.sanjiang.service.ISjSafeEnvironmentFileService;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 三江安全环保资料中心
|
||||
@ -24,8 +39,12 @@ import java.util.List;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SjSafeEnvironmentFileServiceImpl extends ServiceImpl<SjSafeEnvironmentFileMapper, SjSafeEnvironmentFile> implements ISjSafeEnvironmentFileService {
|
||||
@Autowired
|
||||
IProjectService projectService;
|
||||
@Autowired
|
||||
private SjSafeEnvironmentFileMapper sjSafeEnvironmentFileMapper;
|
||||
@Value("${basePath}")
|
||||
private String basePath;
|
||||
|
||||
@Override
|
||||
public void addProjectFile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
@ -48,7 +67,15 @@ public class SjSafeEnvironmentFileServiceImpl extends ServiceImpl<SjSafeEnvironm
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renamefile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
public Result renamefile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
String sn = sjSafeEnvironmentFile.getSn();
|
||||
if (StringUtils.isBlank(sn)) {
|
||||
return Result.error("sn不能为空");
|
||||
}
|
||||
List<String> projectSnList = getProjectSnList(sn);
|
||||
if (CollectionUtil.isEmpty(projectSnList)) {
|
||||
return Result.error("查询不到项目sn");
|
||||
}
|
||||
SjSafeEnvironmentFile oldSjSafeEnvironmentFile = sjSafeEnvironmentFileMapper.selectById(sjSafeEnvironmentFile.getFileId());
|
||||
QueryWrapper<SjSafeEnvironmentFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SjSafeEnvironmentFile::getProjectSn, oldSjSafeEnvironmentFile.getProjectSn())
|
||||
@ -67,19 +94,24 @@ public class SjSafeEnvironmentFileServiceImpl extends ServiceImpl<SjSafeEnvironm
|
||||
String time = df.format(new Date());
|
||||
if (1 == oldSjSafeEnvironmentFile.getIsDir()) {
|
||||
SjSafeEnvironmentFile newSjSafeEnvironmentFile = new SjSafeEnvironmentFile();
|
||||
newSjSafeEnvironmentFile.setFileId(oldSjSafeEnvironmentFile.getFileId());
|
||||
newSjSafeEnvironmentFile.setUploadTime(time);
|
||||
newSjSafeEnvironmentFile.setFileName(sjSafeEnvironmentFile.getFileName());
|
||||
sjSafeEnvironmentFileMapper.updateById(newSjSafeEnvironmentFile);
|
||||
sjSafeEnvironmentFileMapper.replaceProjectFilePath(oldSjSafeEnvironmentFile.getFilePath() + sjSafeEnvironmentFile.getFileName() + "/",
|
||||
oldSjSafeEnvironmentFile.getFilePath() + oldSjSafeEnvironmentFile.getFileName() + "/", oldSjSafeEnvironmentFile.getProjectSn());
|
||||
sjSafeEnvironmentFileMapper.update(newSjSafeEnvironmentFile, new LambdaQueryWrapper<SjSafeEnvironmentFile>()
|
||||
.in(SjSafeEnvironmentFile::getProjectSn, projectSnList)
|
||||
.eq(SjSafeEnvironmentFile::getFilePath, sjSafeEnvironmentFile.getFilePath())
|
||||
.eq(SjSafeEnvironmentFile::getFileName, sjSafeEnvironmentFile.getFileName())
|
||||
);
|
||||
sjSafeEnvironmentFileMapper.replaceProjectFilePathAndProjectSnList(oldSjSafeEnvironmentFile.getFilePath() + sjSafeEnvironmentFile.getFileName() + "/",
|
||||
oldSjSafeEnvironmentFile.getFilePath() + oldSjSafeEnvironmentFile.getFileName() + "/", projectSnList);
|
||||
} else {
|
||||
SjSafeEnvironmentFile newSjSafeEnvironmentFile = new SjSafeEnvironmentFile();
|
||||
newSjSafeEnvironmentFile.setFileId(oldSjSafeEnvironmentFile.getFileId());
|
||||
newSjSafeEnvironmentFile.setUploadTime(time);
|
||||
newSjSafeEnvironmentFile.setFileName(sjSafeEnvironmentFile.getFileName());
|
||||
sjSafeEnvironmentFileMapper.updateById(newSjSafeEnvironmentFile);
|
||||
sjSafeEnvironmentFileMapper.update(newSjSafeEnvironmentFile, new LambdaQueryWrapper<SjSafeEnvironmentFile>()
|
||||
.in(SjSafeEnvironmentFile::getProjectSn, projectSnList)
|
||||
.eq(SjSafeEnvironmentFile::getFileUrl, sjSafeEnvironmentFile.getFileUrl()));
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,34 +122,136 @@ public class SjSafeEnvironmentFileServiceImpl extends ServiceImpl<SjSafeEnvironm
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
public Result deleteFile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
String sn = sjSafeEnvironmentFile.getSn();
|
||||
if (StringUtils.isBlank(sn)) {
|
||||
return Result.error("sn不能为空");
|
||||
}
|
||||
List<String> projectSnList = getProjectSnList(sn);
|
||||
if (CollectionUtil.isEmpty(projectSnList)) {
|
||||
return Result.error("查询不到项目sn");
|
||||
}
|
||||
SjSafeEnvironmentFile oldSjSafeEnvironmentFile = sjSafeEnvironmentFileMapper.selectById(sjSafeEnvironmentFile.getFileId());
|
||||
if (1 == oldSjSafeEnvironmentFile.getIsDir()) {
|
||||
String filePath = oldSjSafeEnvironmentFile.getFilePath() + oldSjSafeEnvironmentFile.getFileName() + "/";
|
||||
QueryWrapper<SjSafeEnvironmentFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SjSafeEnvironmentFile::getProjectSn, oldSjSafeEnvironmentFile.getProjectSn())
|
||||
queryWrapper.lambda().in(SjSafeEnvironmentFile::getProjectSn, projectSnList)
|
||||
.likeRight(SjSafeEnvironmentFile::getFilePath, filePath);
|
||||
sjSafeEnvironmentFileMapper.delete(queryWrapper);
|
||||
sjSafeEnvironmentFileMapper.deleteById(sjSafeEnvironmentFile.getFileId());
|
||||
} else {
|
||||
sjSafeEnvironmentFileMapper.deleteById(sjSafeEnvironmentFile.getFileId());
|
||||
sjSafeEnvironmentFileMapper.delete(new LambdaQueryWrapper<SjSafeEnvironmentFile>().in(SjSafeEnvironmentFile::getProjectSn, projectSnList)
|
||||
.eq(SjSafeEnvironmentFile::getFileUrl, oldSjSafeEnvironmentFile.getFileUrl()));
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveFile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
SjSafeEnvironmentFile oldSjSafeEnvironmentFile = sjSafeEnvironmentFileMapper.selectById(sjSafeEnvironmentFile.getFileId());
|
||||
public Result moveFile(SjSafeEnvironmentFile sjSafeEnvironmentFile) {
|
||||
String sn = sjSafeEnvironmentFile.getSn();
|
||||
if (StringUtils.isBlank(sn)) {
|
||||
return Result.error("sn不能为空");
|
||||
}
|
||||
List<String> projectSnList = getProjectSnList(sjSafeEnvironmentFile.getSn());
|
||||
if (CollectionUtil.isEmpty(projectSnList)) {
|
||||
return Result.error("查询不到项目sn");
|
||||
}
|
||||
|
||||
//移动根目录
|
||||
sjSafeEnvironmentFileMapper.updateFilepathByPathAndName(sjSafeEnvironmentFile);
|
||||
SjSafeEnvironmentFile oldSjSafeEnvironmentFile = sjSafeEnvironmentFileMapper.selectById(sjSafeEnvironmentFile.getFileId());
|
||||
SjSafeEnvironmentFile s = new SjSafeEnvironmentFile();
|
||||
s.setFilePath(sjSafeEnvironmentFile.getFilePath());
|
||||
sjSafeEnvironmentFileMapper.update(s, new LambdaQueryWrapper<SjSafeEnvironmentFile>()
|
||||
.in(SjSafeEnvironmentFile::getProjectSn, projectSnList)
|
||||
.eq(SjSafeEnvironmentFile::getFileUrl, oldSjSafeEnvironmentFile.getFileUrl()));
|
||||
|
||||
//移动子目录
|
||||
if (1 == oldSjSafeEnvironmentFile.getIsDir()) {
|
||||
//移动子目录
|
||||
String oldfilePath = oldSjSafeEnvironmentFile.getFilePath() + oldSjSafeEnvironmentFile.getFileName() + "/";
|
||||
String newfilePath = sjSafeEnvironmentFile.getFilePath() + oldSjSafeEnvironmentFile.getFileName() + "/";
|
||||
oldfilePath = oldfilePath.replace("\\", "\\\\\\\\");
|
||||
oldfilePath = oldfilePath.replace("'", "\\'");
|
||||
oldfilePath = oldfilePath.replace("%", "\\%");
|
||||
oldfilePath = oldfilePath.replace("_", "\\_");
|
||||
sjSafeEnvironmentFileMapper.updateFilepathByFilepath(oldfilePath, newfilePath, oldSjSafeEnvironmentFile.getProjectSn());
|
||||
sjSafeEnvironmentFileMapper.updateFilepathByFilepathAndProjectSnList(oldfilePath, newfilePath, projectSnList);
|
||||
}
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto) {
|
||||
String sn = request.getParameter("sn");
|
||||
if (StringUtils.isBlank(sn)) {
|
||||
return Result.error("sn不能为空");
|
||||
}
|
||||
Result<UploadFileVo> restResult = new Result<>();
|
||||
uploadFileDto.setSn(sn);
|
||||
doUploadFile(request, uploadFileDto);
|
||||
UploadFileVo uploadFileVo = new UploadFileVo();
|
||||
restResult.data(uploadFileVo);
|
||||
return restResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getFileList(Map<String, Object> map) {
|
||||
List<String> projectSnList = getProjectSnList(MapUtils.getString(map, "sn"));
|
||||
if (CollectionUtil.isEmpty(projectSnList)) {
|
||||
return Result.error("查询不到项目sn");
|
||||
}
|
||||
QueryWrapper<SjSafeEnvironmentFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda()
|
||||
.in(SjSafeEnvironmentFile::getProjectSn, projectSnList)
|
||||
.eq(SjSafeEnvironmentFile::getFilePath, MapUtils.getString(map, "filePath"));
|
||||
queryWrapper.orderByAsc("is_dir");
|
||||
List<SjSafeEnvironmentFile> list = list(queryWrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找projectSn,sn(项目SN或企业sn)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<String> getProjectSnList(String sn) {
|
||||
if (StringUtils.isBlank(sn)) {
|
||||
return null;
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
List<EntityMap> entityMaps = projectService.selectAllProjectInfoList(map);
|
||||
List<String> projectSnList = entityMaps.stream().map(m -> MapUtils.getString(m, "projectSn")).collect(Collectors.toList());
|
||||
return projectSnList;
|
||||
}
|
||||
|
||||
private void doUploadFile(HttpServletRequest request, UploadFileDTO u) {
|
||||
List<String> projectSnList = getProjectSnList(u.getSn());
|
||||
ArrayList<SjSafeEnvironmentFile> list = new ArrayList<>();
|
||||
UploadFile uploadFile = new UploadFile();
|
||||
uploadFile.setChunkNumber(u.getChunkNumber());
|
||||
uploadFile.setChunkSize(u.getChunkSize());
|
||||
uploadFile.setTotalChunks(u.getTotalChunks());
|
||||
uploadFile.setIdentifier(u.getIdentifier());
|
||||
uploadFile.setTotalSize(u.getTotalSize());
|
||||
uploadFile.setCurrentChunkSize(u.getCurrentChunkSize());
|
||||
Uploader uploader = new ChunkUploaderFactory().getUploader(uploadFile);
|
||||
List<UploadFile> uploadFileList = uploader.upload(request, basePath);
|
||||
for (int i = 0; i < uploadFileList.size(); i++) {
|
||||
uploadFile = uploadFileList.get(i);
|
||||
if (uploadFile.getSuccess() == 1) {
|
||||
for (String projectSn : projectSnList) {
|
||||
SjSafeEnvironmentFile userFile = new SjSafeEnvironmentFile();
|
||||
userFile.setExtendName(uploadFile.getFileType());
|
||||
userFile.setFileName(uploadFile.getFileName());
|
||||
userFile.setFilePath(u.getFilePath());
|
||||
userFile.setProjectSn(projectSn);
|
||||
userFile.setIsDir(0);
|
||||
userFile.setFileUrl(uploadFile.getUrl());
|
||||
userFile.setFileSize(uploadFile.getFileSize() + "");
|
||||
userFile.setUploadTime(DateUtil.getCurrentTime());
|
||||
list.add(userFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
saveBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user