企业标准产品标准附件重复问题
This commit is contained in:
+5
@@ -433,5 +433,10 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
|
||||
return sarBussionessStandEOService.repetitionFile();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|SarBussionessStand|新系统企业库(产品标准)附件重复问题")
|
||||
@GetMapping("/newRpetitionFile")
|
||||
public ResponseMessage newRpetitionFile (){
|
||||
return sarBussionessStandEOService.newRpetitionFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -122,5 +122,9 @@ public interface SarBussionessStandDao extends BaseMapper<SarBussionessStand> {
|
||||
void importSarBussionessStand(SarBussionessStand sarBussionessStands);
|
||||
|
||||
List<OldSystem> selectListInfo();
|
||||
|
||||
List<OldSystem> getBussionessStandInfo();
|
||||
|
||||
void updateByIdInfo(@Param("strFile")String strFile, @Param("attfId")String attfId);
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -61,5 +61,7 @@ public interface ISarBussionessStandService extends IService<SarBussionessStand>
|
||||
ResponseMessage<String> importSarBussionessStandFile(MultipartFile file)throws Exception;
|
||||
|
||||
ResponseMessage repetitionFile();
|
||||
|
||||
ResponseMessage newRpetitionFile();
|
||||
}
|
||||
|
||||
|
||||
+115
@@ -122,6 +122,7 @@ import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -3791,6 +3792,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
||||
}
|
||||
return Result.success(null,"数量="+set.size()+"====",set);
|
||||
}
|
||||
|
||||
public Set<AttFileEO> newFileNameRepetition(List<String> asList){
|
||||
List<AttFileEO> attFileEOS = new ArrayList<>();
|
||||
Set<AttFileEO> attFileEOArrayList = new HashSet<>();
|
||||
@@ -3847,4 +3849,117 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
||||
}
|
||||
return attFileEOArrayList;
|
||||
}
|
||||
@Override
|
||||
public ResponseMessage newRpetitionFile() {
|
||||
Set<String> objects = new HashSet<>();
|
||||
// 名称一致 大小一致 则为重复
|
||||
//新系统产品标准 重复附件清除问题 字段修改 文件删除
|
||||
List<OldSystem> sarBussionessStandList = sarBussionessStandEODao.getBussionessStandInfo();
|
||||
if(!sarBussionessStandList.isEmpty()){
|
||||
for (OldSystem data : sarBussionessStandList){
|
||||
if(StringUtils.isNotBlank(data.getFileId())){
|
||||
if(data.getFileId().contains(",")){
|
||||
//不包含逗号则证明为一条,一条则不处理
|
||||
String[] split = data.getFileId().split(",");
|
||||
List<String> asList = Arrays.asList(split);
|
||||
if(!asList.isEmpty() && StringUtils.isNotBlank(data.getStandId())){
|
||||
String str = updateInfo(asList, data.getStandId(), data.getAttfid());
|
||||
if(StringUtils.isNotBlank(str)){
|
||||
objects.add(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success(objects);
|
||||
}
|
||||
|
||||
public String updateInfo(List<String> asList,String standId,String attfId) {
|
||||
//重复的集合
|
||||
List<AttFileEO> chongfu = new ArrayList<>();
|
||||
//所有数据的集合
|
||||
List<AttFileEO> attFileEOArrayList = new ArrayList<>();
|
||||
//辅助循环的集合
|
||||
List<AttFileEO> rocorArrayList = new ArrayList<>();
|
||||
//非重复的集合
|
||||
List<AttFileEO> notRepetitionList = new ArrayList<>();
|
||||
for (String fileId:asList){
|
||||
AttFileEO byId = attFileEOService.getFileInfo(fileId);
|
||||
if(byId!=null) {
|
||||
attFileEOArrayList.add(byId);
|
||||
}
|
||||
}
|
||||
String strFileInfo = "";
|
||||
String strFile = "";
|
||||
if(!attFileEOArrayList.isEmpty()) {
|
||||
for (int i = 0; i <attFileEOArrayList.size() ; i++) {
|
||||
if(rocorArrayList.size()==0){
|
||||
rocorArrayList.add(attFileEOArrayList.get(i));
|
||||
}else {
|
||||
boolean tr = false;
|
||||
for (int j = 0; j <rocorArrayList.size() ; j++) {
|
||||
if(!attFileEOArrayList.get(i).getId().equals(rocorArrayList.get(j).getId())){
|
||||
//首先两个id不能一致 名称一致
|
||||
if(attFileEOArrayList.get(i).getOldFileName().equals(rocorArrayList.get(j).getOldFileName())){
|
||||
File file1 = new File("E:/data/slrs/file/" + attFileEOArrayList.get(i).getFilePath() + attFileEOArrayList.get(i).getFileName());
|
||||
File file2 = new File("E:/data/slrs/file/" + rocorArrayList.get(j).getFilePath() + rocorArrayList.get(j).getFileName());
|
||||
long length1 = file1.length();
|
||||
long length2 = file2.length();
|
||||
if(length1 == length2){
|
||||
// 存在重复 需要被清除的数据
|
||||
tr = true;
|
||||
chongfu.add(attFileEOArrayList.get(i));
|
||||
logger.info("当前数据为重复数据:=====企业数据id=" + standId+"文件Id:"+attFileEOArrayList.get(i).getId()+"==="+attFileEOArrayList.get(i).getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tr){
|
||||
rocorArrayList.add(attFileEOArrayList.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AttFileEO data: attFileEOArrayList) {
|
||||
notRepetitionList.add(data);
|
||||
}
|
||||
if(!chongfu.isEmpty()) {
|
||||
for (AttFileEO data : attFileEOArrayList) {
|
||||
for (AttFileEO attFileEO : chongfu) {
|
||||
if (data.getId().equals(attFileEO.getId())) {
|
||||
notRepetitionList.remove(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 不重复的集合 notRepetitionList
|
||||
if(!notRepetitionList.isEmpty()) {
|
||||
for (AttFileEO attFileEO : notRepetitionList) {
|
||||
if (StringUtils.isNotBlank(strFile)) {
|
||||
strFile = strFile + "," + attFileEO.getId();
|
||||
} else {
|
||||
strFile = attFileEO.getId();
|
||||
}
|
||||
}
|
||||
// 更新数据库
|
||||
sarBussionessStandEODao.updateByIdInfo(strFile,attfId);
|
||||
logger.info("更新数据库==="+strFile);
|
||||
}
|
||||
// 删除重复的文件
|
||||
if(!chongfu.isEmpty()){
|
||||
for (AttFileEO data : chongfu){
|
||||
if (StringUtils.isNotBlank(strFileInfo)) {
|
||||
strFileInfo = strFileInfo + "," + data.getId();
|
||||
} else {
|
||||
strFileInfo = data.getId();
|
||||
}
|
||||
File file = new File("E:/data/slrs/file/"+data.getFilePath()+data.getOldFileName());
|
||||
file.delete();
|
||||
logger.info("删除文件成功(逻辑删除)======"+data.getFilePath()+data.getOldFileName());
|
||||
attFileEOService.deleteById(data.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return "标准Id==="+standId+"修改文件==="+strFile+"删除文件=="+strFileInfo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user