Merge remote-tracking branch 'origin/develop_master' into develop_master

This commit is contained in:
CD
2022-10-14 10:46:46 +08:00
13 changed files with 504 additions and 49 deletions
@@ -5,14 +5,23 @@ import com.adc.da.base.web.BaseController;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandardsInfo.entity.ActSarItemsEO;
import com.adc.da.workFlow.entity.GetQBZXDExcelDto;
import com.adc.da.workFlow.service.ActSarItemsBussEOService;
import com.adc.da.workFlow.service.ActSarItemsLawsEOService;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/${restPath}/lawss/actSarItemsBuss")
@Api(description = "|ActSarItemsBuss|")
@@ -50,4 +59,66 @@ public class ActSarItemsBussEOController extends BaseController<ActSarItemsEO> {
public void autoUpdIndex(@RequestParam("pid") String pid,@RequestParam("bussId") String bussId) {
actSarItemsEOService.autoUpdIndex(pid,bussId);
}
@ApiOperation(value = "导出全部意见-企标制修订-技术标准-起草单位高级经理审核节点")
@PostMapping("/exportAllBZZXDJSBZ")
public void getAllStandYJCL(HttpServletResponse response, @RequestBody Map<String, String> params){
try {
net.sf.json.JSONArray jsonArray = net.sf.json.JSONArray.fromObject(params.get("json"));
List<Map<String, String>> data = (List<Map<String, String>>) jsonArray;
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String textName="意见信息";
Map<String,String> map=new HashMap<>();
map.put("1","采纳");
map.put("2","部分采纳");
map.put("3","不采纳");
String fileName = URLEncoder.encode(textName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
data = data.stream().sorted(Comparator.comparing(m->m.get("modelNum"))).collect(Collectors.toList());
List<GetQBZXDExcelDto> standExcel=new ArrayList<>();
int i=0;
for (Map<String, String> idea : data){
i++;
GetQBZXDExcelDto getExcelDto = GetQBZXDExcelDto.builder()
.partCode(idea.get("modelNum"))
.oldText(idea.get("modelUpdBefore"))
.newText(idea.get("modelUpdAfter"))
.reason(idea.get("modelContent"))
.userName(idea.get("zrUserIdName"))
.deptName(idea.get("zrDeptIdName"))
.state(map.get(idea.get("opinionsAdopted")))
.cause(idea.get("opinionsAdoptedCont"))
.num(String.valueOf(i))
.build();
standExcel.add(getExcelDto);
}
List<List<String>> headList=new ArrayList<List<String>>();
headList.add(Lists.newArrayList("序号"));
headList.add(Lists.newArrayList("条款号"));
headList.add(Lists.newArrayList("修改前"));
headList.add(Lists.newArrayList("修改后"));
headList.add(Lists.newArrayList("修改理由"));
headList.add(Lists.newArrayList("提出部门"));
headList.add(Lists.newArrayList("责任人"));
headList.add(Lists.newArrayList("意见是否采纳"));
headList.add(Lists.newArrayList("采纳原因"));
EasyExcel.write(response.getOutputStream(), GetQBZXDExcelDto.class).head(headList).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(standExcel);
} catch (Exception e) {
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
try {
response.getWriter().println(JSON.toJSONString(Result.error()));
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}
@@ -0,0 +1,35 @@
package com.adc.da.workFlow.entity;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@HeadRowHeight(20)
@ColumnWidth(15)
public class GetQBZXDExcelDto {
private String num; // 序号
private String partCode; // 条款号
private String oldText; // 修改前
private String newText; // 修改后
private String reason; // 修改理由
private String deptName; // 提出部门
private String userName; // 责任人
private String state; // 意见是否采纳
private String cause; // 采纳理由
}
@@ -73,6 +73,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
//从excl中导入标准
addInterceptor.excludePathPatterns("/api/ImportExcel/import");
//企标制修订-技术标准 意见导出
addInterceptor.excludePathPatterns("/api/lawss/actSarItemsBuss/exportAllBZZXDJSBZ");
//标准征求意见导出
addInterceptor.excludePathPatterns("/api/slrs/sar-public-idea-all/tuallStand");
// 标准征求意见流程意见导出
@@ -112,6 +114,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
//预警导出
addInterceptor.excludePathPatterns("/api/sys/EarlyWarning/exportWarning");
//标准文件检查接口
addInterceptor.excludePathPatterns("/api/scheduled/checkFileByEncrypt");
//OCR回调存储文件
addInterceptor.excludePathPatterns("/api/ocr/OCRRestful/OcrHandleResult");
@@ -35,7 +35,7 @@ public class SwaggerConfig {
ParameterBuilder tokenPar = new ParameterBuilder();
List<Parameter> pars = new ArrayList<>();
tokenPar.name("Authorization")
tokenPar.name("token")
.description("令牌")
.modelRef(new ModelRef("string"))
.parameterType("header")
@@ -0,0 +1,34 @@
package com.adc.da.scheduled;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
@EnableScheduling
@Component
@Slf4j
public class CheckEncryFileJob {
@Autowired
ISarBussionessStandService iSarBussionessStandService;
@Autowired
ISarStandardsInfoService iSarStandardsInfoService;
@Async
public void asyncCheckBussStandEncryptFile(){
iSarBussionessStandService.checkFileByEncrypt();
}
@Async
public void asyncCheckStandEncryptFile(){
iSarStandardsInfoService.checkFileByEncrypt();
}
}
@@ -1,12 +1,13 @@
package com.adc.da.scheduled.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.scheduled.CheckEncryFileJob;
import com.adc.da.scheduled.ScheduledJob;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/${restPath}/scheduled")
@@ -17,6 +18,9 @@ public class Controller {
@Autowired
ScheduledJob scheduledJob;
@Autowired
CheckEncryFileJob checkEncryFileJob;
@PutMapping("/warning")
public void warning(){
scheduledJob.warningSchedulingTasks();
@@ -28,4 +32,12 @@ public class Controller {
}
@ApiOperation(value = "标准原始文件判断是否是加密文件")
@GetMapping("/checkFileByEncrypt")
public ResponseMessage checkFileByEncrypt() {
checkEncryFileJob.asyncCheckStandEncryptFile();
checkEncryFileJob.asyncCheckBussStandEncryptFile();
return Result.success("开始判断中稍后到服务器中查看文件");
}
}
@@ -11,6 +11,7 @@ import com.adc.da.sys.service.IDicTypeEOService;
import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -52,9 +53,10 @@ public class exportWkExcel {
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.HSSF);
exportParams.setSheetName(exportName);
List<String> types=new ArrayList<>();
types.add("BUSSSTANDCLASS");
Map<String, Object> dicTypeEO = dicTypeEOService.getDicTypeListCodeByType(types);
// List<String> types=new ArrayList<>();
// types.add("BUSSSTANDCLASS");
// Map<String, Object> dicTypeEO = dicTypeEOService.getDicTypeListCodeByType(types);
Map<String, Object> dicTypeEO = getBussStandTypeData();
workbook = ExcelExportUtilByWk.getHSSFWorkbook(exportParams, exportExcel.class,workbook,"1",dicTypeEO);
os = response.getOutputStream();
workbook.write(os);
@@ -66,6 +68,24 @@ public class exportWkExcel {
}
}
/**
* 静态加载企标类别下拉框
* @return
*/
private static Map<String,Object> getBussStandTypeData(){
Map<String,Object> resultMap = new HashMap<>();
List<Map<String,String>> bussStandTypeList = new ArrayList<>();
char letter = 'A';
for(letter = 'A'; letter <= 'Z'; ++letter){
Map<String,String> typeMap = new HashMap<>();
typeMap.put("Q/FT "+letter,"Q/FT "+letter);
bussStandTypeList.add(typeMap);
}
resultMap.put("BUSSSTANDCLASS",bussStandTypeList);
return resultMap;
}
@ApiOperation(value = "|SarFileSplitItemsEO|导入")
@PostMapping(value = "/importData")
public ResponseMessage<?> importSplitItemsZip(@RequestParam(value = "importFileId", required = false) String importFileId) throws Exception {
@@ -365,5 +365,9 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
return "1";
}
}
@@ -51,5 +51,8 @@ public interface ISarBussionessStandService extends IService<SarBussionessStand>
List<SarBussionessStand> getSarBussionStandPageQd(SarBussionessStandEOPage page) throws Exception;
void convertDocAllQB(List<SarBussStandFile> list);
void checkFileByEncrypt();
}
@@ -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
}
}
/**
* 判断文件是否是加密文件
*/
@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("VALID_FLAG",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);
logger.debug(checkResult);
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("================================文件检查完毕==================================================");
}
}
@@ -1,6 +1,5 @@
package com.adc.da.slrs.sarStandardsInfo.service;
import com.adc.da.slrs.sarBussStandFile.entity.SarBussStandFile;
import com.adc.da.slrs.sarStandFile.entity.SarStandFile;
import com.adc.da.slrs.sarStandardsInfo.entity.*;
import com.adc.da.http.ResponseMessage;
@@ -71,5 +70,6 @@ public interface ISarStandardsInfoService extends IService<SarStandardsInfo> {
void convertDocAll(List<SarStandFile> list);
void checkFileByEncrypt();
}
@@ -11,18 +11,11 @@ import com.adc.da.slrs.regulations.entity.SearchStandContext;
import com.adc.da.slrs.regulations.entity.StandData;
import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao;
import com.adc.da.slrs.sarBussStandAttrInfo.entity.SarBussStandAttrInfo;
import com.adc.da.slrs.sarBussStandAttrInfo.service.ISarBussStandAttrInfoService;
import com.adc.da.slrs.sarBussStandFile.entity.SarBussStandFile;
import com.adc.da.slrs.sarBussStandFile.service.ISarBussStandFileService;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarLawsAttrDetailedListDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarFindDto;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import com.adc.da.slrs.sarPosition.service.ITsPositionService;
import com.adc.da.slrs.sarStandAttrInfo.service.ISarStandAttrInfoService;
import com.adc.da.slrs.sarStandFile.service.ISarStandFileService;
import com.adc.da.slrs.sarStandWarning.dao.WarningDateDao;
import com.adc.da.slrs.sarStandWarning.entity.WarningDate;
import com.adc.da.slrs.sarStandWarning.service.Impl.WarningDateServiceImpl;
import com.adc.da.slrs.sarUser.entity.TsUser;
@@ -79,10 +72,6 @@ import com.adc.da.slrs.standardSplit.dao.SarFileSplitInfoEODao;
import com.adc.da.slrs.standardSplit.entity.SarFileSplitInfoEO;
import com.adc.da.slrs.standardSplit.entity.SarFileSplitInfoEOPage;
import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
import com.adc.da.slrs.tsDictionaryType.dao.TsDicTypeDao;
import com.adc.da.slrs.tsDictionaryType.dao.TsDictionaryDao;
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.entity.TsDictionary;
import com.adc.da.sys.common.SelectionResult;
import com.adc.da.sys.constant.ValueStateEnum;
import com.adc.da.sys.dao.DicTypeEODao;
@@ -97,7 +86,6 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sf.json.JSONObject;
import org.apache.catalina.User;
import org.apache.commons.lang3.StringUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFTextStripper;
@@ -113,8 +101,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
@@ -254,28 +242,6 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
@Autowired
private StandLawsSearchService standLawsSearchService;
@Autowired
private ISarMenuStandardService standardService;
@Autowired
private TsDictionaryDao tsDictionaryDao;
@Autowired
private TsDicTypeDao tsDicTypeDao;
@Autowired
private ISarStandAttrInfoService iSarStandAttrInfoService;
@Autowired
private ISarStandardsInfoService sarStandardsInfoService;
@Autowired
private ISarBussStandAttrInfoService iSarBussStandAttrInfoService;
@Autowired
private ISarBussionessStandService iSarBussionessStandService;
@Autowired
private SarBussStandAttrInfoDao standAttrInfoDao;
@@ -289,6 +255,9 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
@Autowired
private INewsFeedService iNewsFeedService;
@Autowired
private EncryptFileUtils encryptFileUtils;
// /**
// * 反向操作标准
// */
@@ -539,6 +508,8 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}
}
@Autowired
private ISarStandFileService sarStandFileService;
@@ -3596,5 +3567,68 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
return sarlist;
}
@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("VALID_FLAG","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);
logger.debug(checkResult);
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,170 @@
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);
logger.debug(hexString);
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";
}
}
public static String checkFileIsEncrypt(String readFilePath){
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);
logger.debug(hexString);
if(readFlag){
if(StringUtils.isNotBlank(hexString)){
if(StringUtils.equals(hexString,ENCRYPT_FILE_HEX)){
return "ENCRYPT";
}else{
return "UNENCRYPT";
}
}else{
return "READNO";
}
}else{
return "READERR";
}
}
/**
* 将文件头转换成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();
}
public static void main(String[] args) {
String filePath ="E:\\FOTONFILE\\sypv9xbkukd6g5fey8w1.DOC";
String s = EncryptFileUtils.checkFileIsEncrypt(filePath);
System.out.println(s);
}
/**
* 本地写TXT文件
* @param path
* @param list
*/
public void writeTxt(List<String> list) {
String savePath = filePath+"/TEMPPATH/"+ UUIDUtils.randomUUID20()+".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();
}
}
}
}