Merge branch 'develop_master' into FOTON
# Conflicts: # adc-da-slrs/src/main/java/com/adc/da/search/server/ResetSearchCenterService.java
This commit is contained in:
@@ -45,6 +45,8 @@ import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.json.JSONTokener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -572,6 +574,16 @@ public class ResetSearchCenterService {
|
||||
page.setStandType("ALL");
|
||||
logger.info("国内外标准查询:" + page.toString());
|
||||
List<SarStandardsInfo> rowsStand = iSarStandardsInfoService.getSarStandardsInfoPage(page);
|
||||
//如果时自动触发,删除需要根据全部的结果进行数据处理
|
||||
SarStandardsInfoEOPage infoEOPage = new SarStandardsInfoEOPage();
|
||||
List<SarStandardsInfo> allStand = null;
|
||||
if (StringUtils.isNotBlank(page.getSyncParam())) {
|
||||
BeanUtils.copyProperties(page, infoEOPage);
|
||||
infoEOPage.setSyncParam(null);
|
||||
allStand = iSarStandardsInfoService.getSarStandardsInfoPage(infoEOPage);
|
||||
}
|
||||
String isAll = null == allStand ? "否" : "是";
|
||||
logger.info("是否查询了全部数据信息:" + isAll);
|
||||
List<SarStandardsInfo> insList = new ArrayList<>();
|
||||
List<SarStandardsInfo> updList = new ArrayList<>();
|
||||
List<String> delList = new ArrayList<>();
|
||||
@@ -604,8 +616,15 @@ public class ResetSearchCenterService {
|
||||
updList.addAll(intersection);
|
||||
}
|
||||
|
||||
List<String> finalStandIdList = null;
|
||||
// 差集 (list2 - list1) 删除
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
|
||||
if (allStand != null && !allStand.isEmpty()) {
|
||||
finalStandIdList = allStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
|
||||
}else{
|
||||
finalStandIdList = rowsStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
|
||||
}
|
||||
List<String> finalStandIdList1 = finalStandIdList;
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
// 可以更新IDLIST 删除 ES
|
||||
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
|
||||
@@ -623,7 +642,7 @@ public class ResetSearchCenterService {
|
||||
for(SarStandardsInfo sarStandardsInfoEO : updList){
|
||||
countUpdateSuccess++;
|
||||
standFunc(sarStandardsInfoEO);
|
||||
createStandMQService.sendStandMQ(sarStandardsInfoEO,"update");
|
||||
// createStandMQService.sendStandMQ(sarStandardsInfoEO,"update");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,13 +653,15 @@ public class ResetSearchCenterService {
|
||||
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
|
||||
sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap()));
|
||||
}
|
||||
createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
|
||||
// createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
|
||||
}
|
||||
}
|
||||
if(!delList.isEmpty() && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
elasticsearchService.deleteBatchId(delList,"stand");
|
||||
elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
if(!delList.isEmpty() && !"sync".equals(page.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
// elasticsearchService.deleteBatchId(delList,"stand");
|
||||
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
logger.info("重置国内外标准:删除-共"+delList.size()+"条数据");
|
||||
}else{
|
||||
logger.info("重置国内外标准:没有删除数据,但应该删除"+delList.size()+"条数据");
|
||||
}
|
||||
logger.info("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+0+"条)删除-共"+delList.size()+"条数据");
|
||||
return Result.success("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+0+"条)删除-共"+delList.size()+"条数据");
|
||||
@@ -1097,6 +1118,16 @@ public class ResetSearchCenterService {
|
||||
if(count2 > 0){
|
||||
sarLawsInfoEOPage.setPageSize(count2);
|
||||
List<SarLawsStandInfo> rowsStand = iSarLawsStandInfoService.getSarStandardsInfoPage(sarLawsInfoEOPage);
|
||||
//如果时自动触发,删除需要根据全部的结果进行数据处理
|
||||
SarLawsStandInfoPage infoEOPage = new SarLawsStandInfoPage();
|
||||
List<SarLawsStandInfo> allStand = null;
|
||||
if (StringUtils.isNotBlank(sarLawsInfoEOPage.getSyncParam())) {
|
||||
BeanUtils.copyProperties(sarLawsInfoEOPage, infoEOPage);
|
||||
infoEOPage.setSyncParam(null);
|
||||
allStand = iSarLawsStandInfoService.getSarStandardsInfoPage(infoEOPage);
|
||||
}
|
||||
String isAll = null == allStand ? "否" : "是";
|
||||
logger.info("是否查询了全部数据信息:" + isAll);
|
||||
List<SarLawsStandInfo> insList = new ArrayList<>();
|
||||
List<SarLawsStandInfo> updList = new ArrayList<>();
|
||||
List<String> delList = new ArrayList<>();
|
||||
@@ -1130,7 +1161,15 @@ public class ResetSearchCenterService {
|
||||
}
|
||||
|
||||
// 差集 (list2 - list1) 删除
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
|
||||
List<String> finalStandIdList = null;
|
||||
// 差集 (list2 - list1) 删除
|
||||
if (allStand != null && !allStand.isEmpty()) {
|
||||
finalStandIdList = allStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
|
||||
}else{
|
||||
finalStandIdList = rowsStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
|
||||
}
|
||||
List<String> finalStandIdList1 = finalStandIdList;
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
// 可以更新IDLIST 删除 ES
|
||||
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
|
||||
@@ -1167,7 +1206,7 @@ public class ResetSearchCenterService {
|
||||
if (sarLawsInfoEO.getAttrInfoMap() != null) {
|
||||
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
|
||||
}
|
||||
createStandMQService.sendLawsMQ(sarLawsInfoEO,"update");
|
||||
// createStandMQService.sendLawsMQ(sarLawsInfoEO,"update");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1197,14 +1236,16 @@ public class ResetSearchCenterService {
|
||||
if (sarLawsInfoEO.getAttrInfoMap() != null) {
|
||||
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
|
||||
}
|
||||
createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
|
||||
// createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
|
||||
}
|
||||
}
|
||||
|
||||
if(!delList.isEmpty() && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
elasticsearchService.deleteBatchId(delList,"laws");
|
||||
elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
if(!delList.isEmpty() && !"sync".equals(sarLawsInfoEOPage.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
// elasticsearchService.deleteBatchId(delList,"laws");
|
||||
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
logger.info("重置国内外政策:删除-共"+delList.size()+"条数据");
|
||||
}else{
|
||||
logger.info("重置国内外政策:没有删除数据,但应该删除"+delList.size()+"条数据");
|
||||
}
|
||||
|
||||
logger.info("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)数据");
|
||||
@@ -1679,7 +1720,16 @@ public class ResetSearchCenterService {
|
||||
sarBussionessStandEOPage.setPageSize(count3);
|
||||
|
||||
List<SarBussionessStand> rowsStand = iSarBussionessStandService.getSarBussionStandPage(sarBussionessStandEOPage);
|
||||
logger.info("企标查询结果" + count3);
|
||||
//如果时自动触发,删除需要根据全部的结果进行数据处理
|
||||
SarBussionessStandEOPage infoEOPage = new SarBussionessStandEOPage();
|
||||
List<SarBussionessStand> allStand = null;
|
||||
if (StringUtils.isNotBlank(sarBussionessStandEOPage.getSyncParam())) {
|
||||
BeanUtils.copyProperties(sarBussionessStandEOPage, infoEOPage);
|
||||
infoEOPage.setSyncParam(null);
|
||||
allStand = iSarBussionessStandService.getSarBussionStandPage(infoEOPage);
|
||||
}
|
||||
String isAll = null == allStand ? "否" : "是";
|
||||
logger.info("是否查询了全部数据信息:" + isAll);
|
||||
List<SarBussionessStand> insList = new ArrayList<>();
|
||||
List<SarBussionessStand> updList = new ArrayList<>();
|
||||
List<String> delList = new ArrayList<>();
|
||||
@@ -1713,8 +1763,15 @@ public class ResetSearchCenterService {
|
||||
updList.addAll(intersection);
|
||||
}
|
||||
|
||||
List<String> finalStandIdList = null;
|
||||
// 差集 (list2 - list1) 删除
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
|
||||
if (allStand != null && !allStand.isEmpty()) {
|
||||
finalStandIdList = allStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
|
||||
}else{
|
||||
finalStandIdList = rowsStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
|
||||
}
|
||||
List<String> finalStandIdList1 = finalStandIdList;
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
// 可以更新IDLIST 删除 ES
|
||||
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
|
||||
@@ -1749,10 +1806,12 @@ public class ResetSearchCenterService {
|
||||
}
|
||||
}
|
||||
|
||||
if(!delList.isEmpty() && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
if(!delList.isEmpty() && !"sync".equals(sarBussionessStandEOPage.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
elasticsearchService.deleteBatchId(delList,"bussstand");
|
||||
elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
logger.info("重置企标:删除-共"+delList.size()+"条数据");
|
||||
}else{
|
||||
logger.info("重置企标:没有删除数据,但应该删除"+delList.size()+"条数据");
|
||||
}
|
||||
logger.info("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)数据");
|
||||
return Result.success("");
|
||||
|
||||
+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("================================文件检查完毕==================================================");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.adc.da.utils.util;
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 加密文件判断工具类
|
||||
*/
|
||||
@Component
|
||||
public class EncryptFileUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(EncryptFileUtils.class);
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
public static final String ENCRYPT_FILE_HEX ="18 1B 03 1A 15 10 19 7C 0A 19 0E 7C 6F 72 6C 5F 5C 5C 5C 5C 5C 5C 5C C3 AD E5 AF 5C 5C 5C 5C 5C 8F EF EF 80 B5 AE 85 B3 94 86 A7 8C 86 E3 A2 FC B5 B4 83 8A B7 8B A9 87 F2 F1 BC F5 8E BF 90 E3 A4 86 8F 8B 94 FC A7 90 A4 EF 87 BC B6 8F 89 B1 F4 8E F7 8D 8A B5 8B 9D F3 89 AA 80 B1 90 82 8C 9F B7 85 A9 B0 89 B2 96 B3 B0 A6 B7 B5 8F 93 E1 AD BD E6 AE 8F 95 92 97 8D F0 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 C5 ";
|
||||
|
||||
|
||||
|
||||
public String checkFileIsEncryFile(AttFileEO fileEO){
|
||||
if(fileEO!=null){
|
||||
String readFilePath = filePath+fileEO.getFilePath()+fileEO.getFileName();
|
||||
boolean readFlag = true;
|
||||
byte[] b = new byte[160];
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = new FileInputStream(readFilePath);
|
||||
inputStream.read(b, 0, 160);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
readFlag = false;
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
String hexString = bytesToHexString(b);
|
||||
if(readFlag){
|
||||
if(StringUtils.isNotBlank(hexString)){
|
||||
if(StringUtils.equals(hexString,ENCRYPT_FILE_HEX)){
|
||||
return "ENCRYPT";
|
||||
}else{
|
||||
return "UNENCRYPT";
|
||||
}
|
||||
}else{
|
||||
return "READNO";
|
||||
}
|
||||
}else{
|
||||
return "READERR";
|
||||
}
|
||||
}else{
|
||||
return "NOFILE";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件头转换成16进制字符串
|
||||
*
|
||||
* @param 原生byte
|
||||
* @return 16进制字符串
|
||||
*/
|
||||
private static String bytesToHexString(byte[] src) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv.toUpperCase()).append(" ");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 本地写TXT文件
|
||||
* @param path
|
||||
* @param list
|
||||
*/
|
||||
public void writeTxt(List<String> list) {
|
||||
String savePath = filePath+"/TEMPPATH/"+ UUIDUtils.randomSnowflakeID()+".txt";
|
||||
BufferedWriter bw = null;
|
||||
FileWriter fr = null;
|
||||
try {
|
||||
//将写入转化为流的形式
|
||||
fr = new FileWriter(savePath);
|
||||
bw = new BufferedWriter(fr);
|
||||
//一次写一行
|
||||
for (String s : list) {
|
||||
bw.write(s);
|
||||
bw.newLine(); //换行用
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bw != null) {
|
||||
bw.close();
|
||||
}
|
||||
if (fr != null) {
|
||||
fr.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user