企业标准产品标准附件重复问题
This commit is contained in:
+5
@@ -433,5 +433,10 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
|
|||||||
return sarBussionessStandEOService.repetitionFile();
|
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);
|
void importSarBussionessStand(SarBussionessStand sarBussionessStands);
|
||||||
|
|
||||||
List<OldSystem> selectListInfo();
|
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<String> importSarBussionessStandFile(MultipartFile file)throws Exception;
|
||||||
|
|
||||||
ResponseMessage repetitionFile();
|
ResponseMessage repetitionFile();
|
||||||
|
|
||||||
|
ResponseMessage newRpetitionFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+115
@@ -122,6 +122,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -3791,6 +3792,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
|||||||
}
|
}
|
||||||
return Result.success(null,"数量="+set.size()+"====",set);
|
return Result.success(null,"数量="+set.size()+"====",set);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<AttFileEO> newFileNameRepetition(List<String> asList){
|
public Set<AttFileEO> newFileNameRepetition(List<String> asList){
|
||||||
List<AttFileEO> attFileEOS = new ArrayList<>();
|
List<AttFileEO> attFileEOS = new ArrayList<>();
|
||||||
Set<AttFileEO> attFileEOArrayList = new HashSet<>();
|
Set<AttFileEO> attFileEOArrayList = new HashSet<>();
|
||||||
@@ -3847,4 +3849,117 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
|||||||
}
|
}
|
||||||
return attFileEOArrayList;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
@@ -1236,4 +1236,22 @@
|
|||||||
where std.BUILD_ID is not null
|
where std.BUILD_ID is not null
|
||||||
and att.FBGBUSS is not null
|
and att.FBGBUSS is not null
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getBussionessStandInfo" resultType="com.adc.da.slrs.sarBussionessStand.entity.OldSystem">
|
||||||
|
SELECT
|
||||||
|
std.id as 'standId',
|
||||||
|
att.id as 'attfid',
|
||||||
|
att.FBGBUSS as 'fileId'
|
||||||
|
from sar_bussioness_stand std
|
||||||
|
left JOIN sar_buss_stand_attr_info att on std.id = att.STAND_ID
|
||||||
|
left join SAR_BUSS_STAND_MENU smenu ON std.id = smenu.buss_stand_id
|
||||||
|
where 1=1
|
||||||
|
and att.FBGBUSS is not null
|
||||||
|
and smenu.MENU_ID = '44'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateByIdInfo" >
|
||||||
|
update sar_buss_stand_attr_info ss set ss.FBGBUSS = #{strFile}
|
||||||
|
where id = #{attfId}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -24,4 +24,5 @@ public interface AttFileEODao extends BaseMapper<AttFileEO> {
|
|||||||
|
|
||||||
public int insertData(AttFileEO attFileEO);
|
public int insertData(AttFileEO attFileEO);
|
||||||
|
|
||||||
|
void deleteByIdInfo(String str, String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,4 +32,6 @@ public interface IAttFileEOService extends IService<AttFileEO> {
|
|||||||
public AttFileVo insertFileInfo(File file,String fileName);
|
public AttFileVo insertFileInfo(File file,String fileName);
|
||||||
|
|
||||||
void downLoadFileList(List<AttFileEO> multiFileInfos, String fileNowPath) throws IOException;
|
void downLoadFileList(List<AttFileEO> multiFileInfos, String fileNowPath) throws IOException;
|
||||||
|
|
||||||
|
void deleteById(String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service("attFileEOService")
|
@Service("attFileEOService")
|
||||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||||
@@ -438,6 +435,17 @@ public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteById(String id) {
|
||||||
|
if(StringUtils.isNotBlank(id)){
|
||||||
|
String[] s = id.split("_");
|
||||||
|
List<String> asList = Arrays.asList(s);
|
||||||
|
String str = "att_file_"+asList.get(2);
|
||||||
|
baseMapper.deleteByIdInfo(str,id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void copyFile1(String srcPath, String destPath) throws IOException {
|
public static void copyFile1(String srcPath, String destPath) throws IOException {
|
||||||
// 打开输入流
|
// 打开输入流
|
||||||
FileInputStream fis = new FileInputStream(srcPath);
|
FileInputStream fis = new FileInputStream(srcPath);
|
||||||
|
|||||||
@@ -100,4 +100,8 @@
|
|||||||
update ${tableName} set OLD_FILE_NAME = #{oldFileName} where id = #{id}
|
update ${tableName} set OLD_FILE_NAME = #{oldFileName} where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteByIdInfo" parameterType="java.lang.String">
|
||||||
|
delete from ${str} where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user