add:检查文件是否为加密文件的判断代码逻辑

This commit is contained in:
zyd
2022-10-12 22:58:48 +08:00
parent 8f74bbfbd9
commit c266ddc4a1
7 changed files with 289 additions and 4 deletions
@@ -899,4 +899,12 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
return "1";
}
@ApiOperation(value = "企业标准原始文件判断是否是加密文件")
@GetMapping("/checkFileByEncrypt")
public ResponseMessage checkFileByEncrypt() {
sarStandardsInfoEOService.checkFileByEncrypt();
return Result.success("开始判断中稍后到服务器中查看文件");
}
}
@@ -71,5 +71,6 @@ public interface ISarStandardsInfoService extends IService<SarStandardsInfo> {
void convertDocAll(List<SarStandFile> list);
void checkFileByEncrypt();
}
@@ -115,6 +115,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -289,6 +290,9 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
@Autowired
private INewsFeedService iNewsFeedService;
@Autowired
private EncryptFileUtils encryptFileUtils;
// /**
// * 反向操作标准
// */
@@ -539,6 +543,8 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}
}
@Autowired
private ISarStandFileService sarStandFileService;
@@ -3596,5 +3602,68 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
return sarlist;
}
@Async
@Override
public void checkFileByEncrypt() {
/**
* 1、获取所有的原始文件
* 2、判断文件头信息
* 3、记录状态
* 4、最后将所有涉及到的文件全部记录到文件中保存到本地
*/
QueryWrapper<SarStandardsInfo> standQueryWrapper = new QueryWrapper<>();
standQueryWrapper.eq("VALID_FLAG","0");
List<SarStandardsInfo> sarStandardsInfos = dao.selectList(standQueryWrapper);
int checkStandNum = 0;
List<String> outLogList = new ArrayList<>();
if(sarStandardsInfos!=null && !sarStandardsInfos.isEmpty()){
for (SarStandardsInfo data:sarStandardsInfos) {
logger.info("开始处理第 "+(checkStandNum++)+" 个标准: "+data.getId()+" "+data.getStandSort()+" "+data.getStandNumber()+"-"+data.getStandYear());
QueryWrapper<SarStandFile> fileQueryWrapper = new QueryWrapper<>();
fileQueryWrapper.eq("STAND_ID",data.getId());
fileQueryWrapper.eq("USE_MODEL","SOURCE_FILE");
fileQueryWrapper.eq("validFlag",0);
List<SarStandFile> sarStandFiles = sarStandFileEODao.selectList(fileQueryWrapper);
if(sarStandFiles!=null && !sarStandFiles.isEmpty()){
for(SarStandFile file : sarStandFiles){
StringBuilder fileLog = new StringBuilder();
String fileAttId = file.getAttId();
if(org.apache.commons.lang.StringUtils.isNotBlank(fileAttId)){
fileLog.append("标准 ").append(data.getStandSort()+" "+data.getStandNumber()+"-"+data.getStandYear()).append(" ").append(data.getId());
fileLog.append(" 下的文件: ").append(file.getId()).append(" ").append(file.getFileName());
//获取文件信息
AttFileEO fileInfo = attFileEOService.getFileInfo(fileAttId);
String checkResult = encryptFileUtils.checkFileIsEncryFile(fileInfo);
switch (checkResult){
case "NOFILE":
fileLog.append(" 检查结果为 不存在该数据 ");
break;
case "READERR":
fileLog.append(" 检查结果为 读取文件失败 ");
break;
case "READNO":
fileLog.append(" 检查结果为 读取文件为空 ");
break;
case "UNENCRYPT":
fileLog.setLength(0);
break;
case "ENCRYPT":
fileLog.append(" 检查结果为 读取文件为空 ");
break;
}
}
if(fileLog.length()>0){
outLogList.add(fileLog.toString());
}
}
}
}
}
if(!outLogList.isEmpty()){
encryptFileUtils.writeTxt(outLogList);
}
logger.info("================================文件检查完毕==================================================");
}
}