add:检查文件是否为加密文件的判断代码逻辑
This commit is contained in:
+9
@@ -365,5 +365,14 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
|
||||
return "1";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "企业标准原始文件判断是否是加密文件")
|
||||
@GetMapping("/checkFileByEncrypt")
|
||||
public ResponseMessage checkFileByEncrypt() {
|
||||
sarBussionessStandEOService.checkFileByEncrypt();
|
||||
return Result.success("开始判断中稍后到服务器中查看文件");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -51,5 +51,8 @@ public interface ISarBussionessStandService extends IService<SarBussionessStand>
|
||||
List<SarBussionessStand> getSarBussionStandPageQd(SarBussionessStandEOPage page) throws Exception;
|
||||
|
||||
void convertDocAllQB(List<SarBussStandFile> list);
|
||||
|
||||
void checkFileByEncrypt();
|
||||
|
||||
}
|
||||
|
||||
|
||||
+72
-4
@@ -57,10 +57,7 @@ import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard;
|
||||
import com.adc.da.sys.sarMenuStandard.service.ISarMenuStandardService;
|
||||
import com.adc.da.sys.util.LoginUserUtil;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import com.adc.da.utils.util.FieldConvertUtil;
|
||||
import com.adc.da.utils.util.InitStandAttrUtil;
|
||||
import com.adc.da.utils.util.SarAdvanceSearchUtil;
|
||||
import com.adc.da.utils.util.Utils;
|
||||
import com.adc.da.utils.util.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.sf.json.JSONObject;
|
||||
@@ -71,6 +68,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Clob;
|
||||
@@ -170,6 +168,10 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
||||
@Autowired
|
||||
private ISarBussStandSnService iSarBussStandSnService;
|
||||
|
||||
@Autowired
|
||||
private EncryptFileUtils encryptFileUtils;
|
||||
|
||||
|
||||
@Override
|
||||
public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus,String standSort,String taskId){
|
||||
SarBussionessStand bussionessStand = new SarBussionessStand();
|
||||
@@ -1808,5 +1810,71 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件是否是加密文件
|
||||
*/
|
||||
@Async
|
||||
@Override
|
||||
public void checkFileByEncrypt() {
|
||||
/**
|
||||
* 1、获取所有的原始文件
|
||||
* 2、判断文件头信息
|
||||
* 3、记录状态
|
||||
* 4、最后将所有涉及到的文件全部记录到文件中保存到本地
|
||||
*/
|
||||
QueryWrapper<SarBussionessStand> standQueryWrapper = new QueryWrapper<>();
|
||||
standQueryWrapper.eq("VALID_FLAG",0);
|
||||
List<SarBussionessStand> sarBussionessStands = sarBussionessStandEODao.selectList(standQueryWrapper);
|
||||
int checkStandNum = 0;
|
||||
List<String> outLogList = new ArrayList<>();
|
||||
if(sarBussionessStands!=null && !sarBussionessStands.isEmpty()){
|
||||
for (SarBussionessStand data:sarBussionessStands) {
|
||||
logger.info("开始处理第 "+(checkStandNum++)+" 个企标: "+data.getId()+" "+data.getStandCode());
|
||||
QueryWrapper<SarBussStandFile> fileQueryWrapper = new QueryWrapper<>();
|
||||
fileQueryWrapper.eq("STAND_ID",data.getId());
|
||||
fileQueryWrapper.eq("USE_MODEL","SOURCE_FILE");
|
||||
fileQueryWrapper.eq("validFlag",0);
|
||||
List<SarBussStandFile> sarBussStandFiles = sarBussStandFileEODao.selectList(fileQueryWrapper);
|
||||
if(sarBussStandFiles!=null && !sarBussStandFiles.isEmpty()){
|
||||
for(SarBussStandFile file : sarBussStandFiles){
|
||||
StringBuilder fileLog = new StringBuilder();
|
||||
String fileAttId = file.getAttId();
|
||||
if(StringUtils.isNotBlank(fileAttId)){
|
||||
fileLog.append("标准 ").append(data.getStandCode()).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("================================文件检查完毕==================================================");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+8
@@ -899,4 +899,12 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
|
||||
return "1";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "企业标准原始文件判断是否是加密文件")
|
||||
@GetMapping("/checkFileByEncrypt")
|
||||
public ResponseMessage checkFileByEncrypt() {
|
||||
sarStandardsInfoEOService.checkFileByEncrypt();
|
||||
return Result.success("开始判断中稍后到服务器中查看文件");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -71,5 +71,6 @@ public interface ISarStandardsInfoService extends IService<SarStandardsInfo> {
|
||||
|
||||
void convertDocAll(List<SarStandFile> list);
|
||||
|
||||
void checkFileByEncrypt();
|
||||
|
||||
}
|
||||
|
||||
+69
@@ -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("================================文件检查完毕==================================================");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user