Compare commits

...

10 Commits

Author SHA1 Message Date
zhanghai 0057b794ba 确保上传后,才返回结果。 1 year ago
zhanglb cdd80baa2e 修复二级分段进不去的错误 2 years ago
zhanglb 8151b43a78 批量上传到3.0 2 years ago
zhanglb 5d57935f0e 代码提交 2 years ago
zhanglb 49c0bfdd0c segment分支 2 years ago
zhanglb 72b8688516 图片上限改1G 2 years ago
zhanglb 50e2e77904 取消图片名称排序 2 years ago
zhanglb 1c3e34fb36 bug修复 2 years ago
zhanglb 6ec3776f18 bug修复 2 years ago
zhanglb 4b441394f9 取消排序 2 years ago

@ -70,12 +70,5 @@ public interface OcrFileInfoApi {
@PutMapping("/edit") @PutMapping("/edit")
void edit(@RequestBody EditOcrFileInfoDTO editOcrFileInfoDTO); void edit(@RequestBody EditOcrFileInfoDTO editOcrFileInfoDTO);
/**
*
*
* @param deleteOcrFileInfoDTO
* @return
*/
@DeleteMapping("/delete")
int delete(@RequestBody DeleteOcrFileInfoDTO deleteOcrFileInfoDTO);
} }

@ -0,0 +1,14 @@
package com.docus.server.dto.segmentation;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel("批量上传参数")
public class UploadPlatformDto {
private String dateStart;
private String dateEnd;
}

@ -4,12 +4,9 @@ import com.docus.server.api.ocr.OcrApi;
import com.docus.server.common.event.FlowEvent; import com.docus.server.common.event.FlowEvent;
import com.docus.server.common.service.IFileUploadService; import com.docus.server.common.service.IFileUploadService;
import com.docus.server.dto.segmentation.UploadBatchFileRequest; import com.docus.server.dto.segmentation.UploadBatchFileRequest;
import com.docus.server.dto.segmentation.UploadPlatformDto;
import com.docus.server.entity.segmentation.OcrFileInfoTest; import com.docus.server.entity.segmentation.OcrFileInfoTest;
import com.docus.server.service.IOcrCutConfigService; import com.docus.server.service.*;
import com.docus.server.service.IOcrCutConfigTestService;
import com.docus.server.service.IOcrFileInfoTestService;
import com.docus.server.service.IOcrVersionService;
import com.docus.server.service.IPublishEventService;
import com.docus.server.service.impl.CommonService; import com.docus.server.service.impl.CommonService;
import com.docus.server.service.impl.PlatformServiceImpl; import com.docus.server.service.impl.PlatformServiceImpl;
import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO; import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO;
@ -18,11 +15,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -53,7 +46,7 @@ public class FileController {
@Resource @Resource
private IPublishEventService iPublishEventService; private IPublishEventService iPublishEventService;
@Resource @Resource
private IOcrFileInfoTestService iOcrFileInfoTestService; private IOcrFileInfoService iOcrFileInfoService;
@Resource @Resource
private IOcrVersionService iOcrVersionService; private IOcrVersionService iOcrVersionService;
@Resource @Resource
@ -89,18 +82,9 @@ public class FileController {
Double widthStart = null; Double widthStart = null;
Double widthEnd = null; Double widthEnd = null;
// if (testData == 1) { if (testData != 1) {
// OcrCutConfigTestVO ocrCutConfigTestVO = iOcrCutConfigTestService.findAll().get(0); iOcrFileInfoService.delete(request.getPatientId());
// height = ocrCutConfigTestVO.getHeight(); }
// widthStart = ocrCutConfigTestVO.getWidthStart();
// widthEnd = ocrCutConfigTestVO.getWidthEnd();
// } else {
// OcrVersion ocrVersion = iOcrVersionService.finEnableVersion();
// OcrCutConfigVO ocrCutConfigVO = iOcrCutConfigService.findByVersion(ocrVersion.getVersion());
// height = ocrCutConfigVO.getHeight();
// widthStart = ocrCutConfigVO.getWidthStart();
// widthEnd = ocrCutConfigVO.getWidthEnd();
// }
List<UploadFileVO> segmentation = iFileUploadService.uploadFile(files, "segmentation", height, widthStart, widthEnd); List<UploadFileVO> segmentation = iFileUploadService.uploadFile(files, "segmentation", height, widthStart, widthEnd);
@ -145,15 +129,16 @@ public class FileController {
return commonService.getOcr(segmentation.get(0), request); return commonService.getOcr(segmentation.get(0), request);
} }
//
// /** /**
// * 下载平台 * 3.0
// * *
// * @throws Exception * @throws Exception
// */ */
// @ApiOperation("批量上传文件到归档系统") @ApiOperation("上传到3.0补偿")
// @GetMapping("/uploadPlatform") @PostMapping("/uploadPlatform")
// public void uploadPlatform() throws Exception { public String uploadPlatform(@RequestBody UploadPlatformDto uploadPlatformDto) {
// downloadService.uploadPlatform(null, null); iOcrFileInfoService.uploadPlatform(uploadPlatformDto);
// } return "成功";
}
} }

@ -84,15 +84,5 @@ public class OcrFileInfoController implements OcrFileInfoApi {
iOcrFileInfoService.edit(editOcrFileInfoDTO); iOcrFileInfoService.edit(editOcrFileInfoDTO);
} }
/**
*
*
* @param deleteOcrFileInfoDTO
* @return
*/
@ApiOperation("批量删除")
@Override
public int delete(DeleteOcrFileInfoDTO deleteOcrFileInfoDTO) {
return iOcrFileInfoService.delete(deleteOcrFileInfoDTO);
}
} }

@ -3,6 +3,7 @@ package com.docus.server.infrastructure.dao;
import com.docus.infrastructure.core.db.dao.IBaseDao; import com.docus.infrastructure.core.db.dao.IBaseDao;
import com.docus.infrastructure.web.request.SearchDTO; import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult; import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.dto.segmentation.UploadPlatformDto;
import com.docus.server.entity.segmentation.OcrFileInfo; import com.docus.server.entity.segmentation.OcrFileInfo;
import java.util.List; import java.util.List;
@ -44,7 +45,7 @@ public interface IOcrFileInfoDao extends IBaseDao<OcrFileInfo> {
* @param ids ids * @param ids ids
* @return * @return
*/ */
int delete(List<Long> ids); int delete(String pid);
/** /**
* *
@ -62,4 +63,6 @@ public interface IOcrFileInfoDao extends IBaseDao<OcrFileInfo> {
* @return * @return
*/ */
int findByIdAndName(Long id, String name); int findByIdAndName(Long id, String name);
List<OcrFileInfo> getUploadInfo(UploadPlatformDto uploadPlatformDto);
} }

@ -6,6 +6,7 @@ import com.docus.core.util.Func;
import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl;
import com.docus.infrastructure.web.request.SearchDTO; import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult; import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.dto.segmentation.UploadPlatformDto;
import com.docus.server.entity.segmentation.OcrBasicTest; import com.docus.server.entity.segmentation.OcrBasicTest;
import com.docus.server.entity.segmentation.OcrFileInfo; import com.docus.server.entity.segmentation.OcrFileInfo;
import com.docus.server.infrastructure.dao.IOcrFileInfoDao; import com.docus.server.infrastructure.dao.IOcrFileInfoDao;
@ -65,8 +66,8 @@ public class OcrFileInfoDaoImpl extends BaseDaoImpl<OcrFileInfoMapper, OcrFileIn
* @return * @return
*/ */
@Override @Override
public int delete(List<Long> ids) { public int delete(String pid) {
return super.deleteByIds(ids); return super.deleteBy("patientId",pid);
} }
/** /**
@ -99,7 +100,7 @@ public class OcrFileInfoDaoImpl extends BaseDaoImpl<OcrFileInfoMapper, OcrFileIn
//默认createTime倒序排序 //默认createTime倒序排序
query.orderByAsc(OcrFileInfo::getPicName); query.orderByAsc(OcrFileInfo::getCreateTime);
List<OcrFileInfo> list = super.find(query); List<OcrFileInfo> list = super.find(query);
return new PageResult<>(list); return new PageResult<>(list);
} }
@ -123,4 +124,12 @@ public class OcrFileInfoDaoImpl extends BaseDaoImpl<OcrFileInfoMapper, OcrFileIn
return baseMapper.selectCount(query); return baseMapper.selectCount(query);
} }
@Override
public List<OcrFileInfo> getUploadInfo(UploadPlatformDto uploadPlatformDto) {
LambdaQueryWrapper<OcrFileInfo> query = Wrappers.lambdaQuery();
query.gt(OcrFileInfo::getOcrFinishTime,uploadPlatformDto.getDateStart());
query.lt(OcrFileInfo::getOcrFinishTime,uploadPlatformDto.getDateEnd());
return baseMapper.selectList(query);
}
} }

@ -93,7 +93,7 @@ public class OcrFileInfoTestDaoImpl extends BaseDaoImpl<OcrFileInfoTestMapper, O
query.eq(OcrFileInfoTest::getPatientId, patientId); query.eq(OcrFileInfoTest::getPatientId, patientId);
} }
//默认createTime倒序排序 //默认createTime倒序排序
query.orderByAsc(OcrFileInfoTest::getPicName); query.orderByAsc(OcrFileInfoTest::getCreateTime);
List<OcrFileInfoTest> list = super.find(query); List<OcrFileInfoTest> list = super.find(query);
return new PageResult<>(list); return new PageResult<>(list);
} }

@ -9,6 +9,7 @@ import com.docus.server.entity.segmentation.ZdAssort;
import com.docus.server.infrastructure.dao.IZdAssortDao; import com.docus.server.infrastructure.dao.IZdAssortDao;
import com.docus.server.infrastructure.mapper.ZdAssortMapper; import com.docus.server.infrastructure.mapper.ZdAssortMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -21,7 +22,8 @@ import java.util.List;
*/ */
@Repository @Repository
public class ZdAssortDaoImpl extends BaseDaoImpl<ZdAssortMapper, ZdAssort> implements IZdAssortDao { public class ZdAssortDaoImpl extends BaseDaoImpl<ZdAssortMapper, ZdAssort> implements IZdAssortDao {
@Value("${ocr.defaultAssortSource}")
private String defaultAssortSource;
/** /**
* *
* *
@ -94,7 +96,7 @@ public class ZdAssortDaoImpl extends BaseDaoImpl<ZdAssortMapper, ZdAssort> imple
// оr(). like(ZdAssort::getXX2, searchDTO.getKeyword())) // оr(). like(ZdAssort::getXX2, searchDTO.getKeyword()))
//); //);
//} //}
query.eq(ZdAssort::getAssortSource, 3); query.eq(ZdAssort::getAssortSource, defaultAssortSource);
query.eq(ZdAssort::getEffective, 1); query.eq(ZdAssort::getEffective, 1);
//默认createTime倒序排序 //默认createTime倒序排序

@ -2,6 +2,7 @@ package com.docus.server.service;
import com.docus.infrastructure.web.request.SearchDTO; import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult; import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.dto.segmentation.UploadPlatformDto;
import com.docus.server.dto.segmentation.ocrfileinfo.AddOcrFileInfoDTO; import com.docus.server.dto.segmentation.ocrfileinfo.AddOcrFileInfoDTO;
import com.docus.server.dto.segmentation.ocrfileinfo.DeleteOcrFileInfoDTO; import com.docus.server.dto.segmentation.ocrfileinfo.DeleteOcrFileInfoDTO;
import com.docus.server.dto.segmentation.ocrfileinfo.EditOcrFileInfoDTO; import com.docus.server.dto.segmentation.ocrfileinfo.EditOcrFileInfoDTO;
@ -53,7 +54,7 @@ public interface IOcrFileInfoService {
* @param deleteOcrFileInfoDTO * @param deleteOcrFileInfoDTO
* @return * @return
*/ */
int delete(DeleteOcrFileInfoDTO deleteOcrFileInfoDTO); int delete(String pid);
/** /**
* *
@ -67,4 +68,6 @@ public interface IOcrFileInfoService {
* *
*/ */
void addBatch(List<AddOcrFileInfoDTO> files); void addBatch(List<AddOcrFileInfoDTO> files);
void uploadPlatform(UploadPlatformDto uploadPlatformDto);
} }

@ -3,6 +3,7 @@ package com.docus.server.service.handler;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.docus.core.util.Func; import com.docus.core.util.Func;
import com.docus.infrastructure.core.db.dao.IBaseDao; import com.docus.infrastructure.core.db.dao.IBaseDao;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.log.annotation.TrackRetryListener; import com.docus.log.annotation.TrackRetryListener;
import com.docus.server.api.ocr.OcrApi; import com.docus.server.api.ocr.OcrApi;
import com.docus.server.common.service.IFileUploadService; import com.docus.server.common.service.IFileUploadService;
@ -23,12 +24,12 @@ import com.docus.server.service.IOcrRuleService;
import com.docus.server.service.IOcrSpecialRuleService; import com.docus.server.service.IOcrSpecialRuleService;
import com.docus.server.service.impl.PlatformServiceImpl; import com.docus.server.service.impl.PlatformServiceImpl;
import com.docus.server.vo.segmentation.ocrcutconfig.OcrCutConfigVO; import com.docus.server.vo.segmentation.ocrcutconfig.OcrCutConfigVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -59,6 +60,12 @@ public class StartSegmentHandler {
private IFileUploadService iFileUploadService; private IFileUploadService iFileUploadService;
@Resource @Resource
private IOcrCutConfigService iOcrCutConfigService; private IOcrCutConfigService iOcrCutConfigService;
@Value("${ocr.defaultAssortId}")
private String defaultAssortId;
@Value("${ocr.defaultAssortName}")
private String defaultAssortName;
@Value("${ocr.defaultSuffix}")
private String defaultSuffix;
@TrackRetryListener("START_SEGMENT") @TrackRetryListener("START_SEGMENT")
public void startSegment(String patientId) { public void startSegment(String patientId) {
@ -75,9 +82,7 @@ public class StartSegmentHandler {
//根据病案号查询文件列表 //根据病案号查询文件列表
List<OcrBasic> ocrBasicList = iOcrBasicDao.findBy("patientId", patientId); List<OcrBasic> ocrBasicList = iOcrBasicDao.findBy("patientId", patientId);
String url = iOcrUrlConfigDao.findBy("version", version).get(0).getUrl(); String url = iOcrUrlConfigDao.findBy("version", version).get(0).getUrl();
List<OcrFileInfo> fileInfoList = iOcrFileInfoDao.findBy("patientId", patientId) List<OcrFileInfo> fileInfoList = iOcrFileInfoDao.findBy("patientId", patientId);
.stream().sorted(Comparator.comparing(OcrFileInfo::getPicName))
.collect(Collectors.toList());
OcrCutConfigVO ocrCutConfigVO = iOcrCutConfigService.findByVersion(ocrVersion.getVersion()); OcrCutConfigVO ocrCutConfigVO = iOcrCutConfigService.findByVersion(ocrVersion.getVersion());
Double height = ocrCutConfigVO.getHeight(); Double height = ocrCutConfigVO.getHeight();
Double widthStart = ocrCutConfigVO.getWidthStart(); Double widthStart = ocrCutConfigVO.getWidthStart();
@ -102,6 +107,7 @@ public class StartSegmentHandler {
//判断上次是否特殊文件开始 需要判断是否特殊文件结尾 //判断上次是否特殊文件开始 需要判断是否特殊文件结尾
if (isSpecialFile) { if (isSpecialFile) {
assortFlag = true;
assortId = lastSpecialResul.getAssortId(); assortId = lastSpecialResul.getAssortId();
assortName = lastSpecialResul.getAssortName(); assortName = lastSpecialResul.getAssortName();
ruleId = lastSpecialResul.getRuleId(); ruleId = lastSpecialResul.getRuleId();
@ -111,7 +117,7 @@ public class StartSegmentHandler {
//当前分段为特殊分段结尾 //当前分段为特殊分段结尾
isSpecialFile = false; isSpecialFile = false;
lastSpecialResul = null; lastSpecialResul = null;
assortFlag = true; assortFlag = false;
} }
} }
//优先判断是否特殊规则开始 //优先判断是否特殊规则开始
@ -142,8 +148,8 @@ public class StartSegmentHandler {
rate = ocrRuleResult.getRate(); rate = ocrRuleResult.getRate();
} else { } else {
if (assortName == null) { if (assortName == null) {
assortId = "-1"; assortId = this.defaultAssortId;
assortName = "其他(无关键字)"; assortName = this.defaultAssortName;
} }
} }
} }
@ -162,7 +168,7 @@ public class StartSegmentHandler {
FileDTO fileDTO = new FileDTO(); FileDTO fileDTO = new FileDTO();
fileDTO.setAssortId(fileInfo.getAssortId()); fileDTO.setAssortId(fileInfo.getAssortId());
fileDTO.setFileTitle(fileInfo.getAssortName()); fileDTO.setFileTitle(fileInfo.getAssortName()+this.defaultSuffix);
fileDTO.setSort(fileInfo.getSort()); fileDTO.setSort(fileInfo.getSort());
fileDTO.setFileType(2); fileDTO.setFileType(2);
fileDTO.setUploadFileName(fileInfo.getPicName()); fileDTO.setUploadFileName(fileInfo.getPicName());
@ -183,12 +189,16 @@ public class StartSegmentHandler {
OcrBasic ocrBasic = ocrBasicList.get(0); OcrBasic ocrBasic = ocrBasicList.get(0);
UploadBatchFileRequest request = new UploadBatchFileRequest(); UploadBatchFileRequest request = new UploadBatchFileRequest();
request.setCollectorId("-1");
request.setInpatientNo(ocrBasic.getInpatientNo()); request.setInpatientNo(ocrBasic.getInpatientNo());
request.setPatientId(patientId); request.setPatientId(patientId);
request.setName(ocrBasic.getName()); request.setName(ocrBasic.getName());
request.setTestData(0); request.setTestData(0);
request.setFileInfo(JSONUtil.toJsonStr(fileDTOList)); request.setFileInfo(JSONUtil.toJsonStr(fileDTOList));
platformService.uploadPlatform(files, request); CommonResult<String> stringCommonResult = platformService.uploadPlatform(files, request);
if(stringCommonResult.getCode()!=0){
throw new RuntimeException("上传3.0失败");
}
} }
} }

@ -13,6 +13,7 @@ import com.docus.server.service.IOcrCutConfigTestService;
import com.docus.server.service.IOcrRuleTestService; import com.docus.server.service.IOcrRuleTestService;
import com.docus.server.service.IOcrSpecialRuleTestService; import com.docus.server.service.IOcrSpecialRuleTestService;
import com.docus.server.vo.segmentation.ocrcutconfigtest.OcrCutConfigTestVO; import com.docus.server.vo.segmentation.ocrcutconfigtest.OcrCutConfigTestVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -42,7 +43,10 @@ public class StartSegmentTestHandler {
private IOcrCutConfigTestService iOcrCutConfigTestService; private IOcrCutConfigTestService iOcrCutConfigTestService;
@Resource @Resource
private IFileUploadService iFileUploadService; private IFileUploadService iFileUploadService;
@Value("${ocr.defaultAssortId}")
private String defaultAssortId;
@Value("${ocr.defaultAssortName}")
private String defaultAssortName;
@TrackRetryListener("START_SEGMENT_TEST") @TrackRetryListener("START_SEGMENT_TEST")
public List<OcrFileInfoTest> startSegment(String patientId) { public List<OcrFileInfoTest> startSegment(String patientId) {
@ -52,9 +56,7 @@ public class StartSegmentTestHandler {
//根据病案号查询文件列表 //根据病案号查询文件列表
List<OcrBasicTest> ocrBasicTestList = iOcrBasicTestDao.findBy("patientId",patientId); List<OcrBasicTest> ocrBasicTestList = iOcrBasicTestDao.findBy("patientId",patientId);
List<OcrFileInfoTest> fileInfoTestList = iOcrFileInfoTestDao.findBy("patientId", patientId) List<OcrFileInfoTest> fileInfoTestList = iOcrFileInfoTestDao.findBy("patientId", patientId);
.stream().sorted(Comparator.comparing(OcrFileInfoTest::getPicName))
.collect(Collectors.toList());
String url = iOcrUrlConfigTestDao.findAll().get(0).getUrl(); String url = iOcrUrlConfigTestDao.findAll().get(0).getUrl();
OcrCutConfigTestVO ocrCutConfigTestVO = iOcrCutConfigTestService.findAll().get(0); OcrCutConfigTestVO ocrCutConfigTestVO = iOcrCutConfigTestService.findAll().get(0);
Double height = ocrCutConfigTestVO.getHeight(); Double height = ocrCutConfigTestVO.getHeight();
@ -81,6 +83,7 @@ public class StartSegmentTestHandler {
fileInfoTest.setOcrFinishTime(new Date()); fileInfoTest.setOcrFinishTime(new Date());
//判断上次是否特殊文件开始 需要判断是否特殊文件结尾 //判断上次是否特殊文件开始 需要判断是否特殊文件结尾
if (isSpecialFile) { if (isSpecialFile) {
assortFlag = true;
assortId = lastSpecialResul.getAssortId(); assortId = lastSpecialResul.getAssortId();
assortName = lastSpecialResul.getAssortName(); assortName = lastSpecialResul.getAssortName();
ruleId = lastSpecialResul.getRuleId(); ruleId = lastSpecialResul.getRuleId();
@ -88,9 +91,9 @@ public class StartSegmentTestHandler {
boolean b = iOcrSpecialRuleTestService.handleSpecialRuleEnd(lastSpecialResul, ocrTextList); boolean b = iOcrSpecialRuleTestService.handleSpecialRuleEnd(lastSpecialResul, ocrTextList);
if (b) { if (b) {
//当前分段为特殊分段结尾 //当前分段为特殊分段结尾
assortFlag = false;
isSpecialFile = false; isSpecialFile = false;
lastSpecialResul = null; lastSpecialResul = null;
assortFlag = true;
} }
} }
@ -126,8 +129,8 @@ public class StartSegmentTestHandler {
rate = ocrRuleResult.getRate(); rate = ocrRuleResult.getRate();
}else { }else {
if (assortName==null){ if (assortName==null){
assortId = "-1"; assortId = this.defaultAssortId;
assortName="其他(无关键字)"; assortName = this.defaultAssortName;
} }
} }
} }

@ -1,21 +1,32 @@
package com.docus.server.service.impl; package com.docus.server.service.impl;
import cn.hutool.json.JSONUtil;
import com.docus.infrastructure.redis.service.IdService; import com.docus.infrastructure.redis.service.IdService;
import com.docus.infrastructure.web.request.SearchDTO; import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult; import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.convert.OcrFileInfoConvert; import com.docus.server.convert.OcrFileInfoConvert;
import com.docus.server.dto.segmentation.FileDTO;
import com.docus.server.dto.segmentation.UploadBatchFileRequest;
import com.docus.server.dto.segmentation.UploadPlatformDto;
import com.docus.server.dto.segmentation.ocrfileinfo.AddOcrFileInfoDTO; import com.docus.server.dto.segmentation.ocrfileinfo.AddOcrFileInfoDTO;
import com.docus.server.dto.segmentation.ocrfileinfo.DeleteOcrFileInfoDTO; import com.docus.server.dto.segmentation.ocrfileinfo.DeleteOcrFileInfoDTO;
import com.docus.server.dto.segmentation.ocrfileinfo.EditOcrFileInfoDTO; import com.docus.server.dto.segmentation.ocrfileinfo.EditOcrFileInfoDTO;
import com.docus.server.entity.segmentation.OcrBasic;
import com.docus.server.entity.segmentation.OcrFileInfo; import com.docus.server.entity.segmentation.OcrFileInfo;
import com.docus.server.infrastructure.dao.IOcrBasicDao;
import com.docus.server.infrastructure.dao.IOcrFileInfoDao; import com.docus.server.infrastructure.dao.IOcrFileInfoDao;
import com.docus.server.service.IOcrFileInfoService; import com.docus.server.service.IOcrFileInfoService;
import com.docus.server.vo.segmentation.ocrfileinfo.OcrFileInfoVO; import com.docus.server.vo.segmentation.ocrfileinfo.OcrFileInfoVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* ocr * ocr
@ -29,7 +40,12 @@ public class OcrFileInfoServiceImpl implements IOcrFileInfoService {
private IOcrFileInfoDao iOcrFileInfoDao; private IOcrFileInfoDao iOcrFileInfoDao;
@Resource @Resource
private IdService idService; private IdService idService;
@Value("${ocr.defaultSuffix}")
private String defaultSuffix;
@Resource
private IOcrBasicDao iOcrBasicDao;
@Resource
private PlatformServiceImpl platformService;
/** /**
* *
* *
@ -89,6 +105,53 @@ public class OcrFileInfoServiceImpl implements IOcrFileInfoService {
iOcrFileInfoDao.saveBatch(ocrFileInfos, 500); iOcrFileInfoDao.saveBatch(ocrFileInfos, 500);
} }
@Override
public void uploadPlatform(UploadPlatformDto uploadPlatformDto) {
Map<String, List<OcrFileInfo>> collect = iOcrFileInfoDao.getUploadInfo(uploadPlatformDto).stream().collect(Collectors.groupingBy(OcrFileInfo::getPatientId));
collect.forEach((k,v)->{
String patientId = k;
List<OcrFileInfo> uploadInfo = v;
List<OcrBasic> ocrBasicList = iOcrBasicDao.findBy("patientId", patientId);
for (OcrFileInfo item:uploadInfo) {
List<FileDTO> fileDTOList = new ArrayList<>(uploadInfo.size());
List<File> files = new ArrayList<>(uploadInfo.size());
File file = new File(item.getPicUrl());
files.add(file);
FileDTO fileDTO = new FileDTO();
fileDTO.setAssortId(item.getAssortId());
fileDTO.setSort(item.getSort());
fileDTO.setFileType(2);
fileDTO.setFileTitle(item.getAssortName()+this.defaultSuffix);
fileDTO.setUploadFileName(item.getPicName());
fileDTO.setSerialNumber(item.getSerialNumber());
fileDTOList.add(fileDTO);
//数据上传到3.0
OcrBasic ocrBasic = ocrBasicList.get(0);
UploadBatchFileRequest request = new UploadBatchFileRequest();
request.setCollectorId("-1");
request.setInpatientNo(ocrBasic.getInpatientNo());
request.setTestData(0);
request.setPatientId(patientId);
request.setName(ocrBasic.getName());
request.setFileInfo(JSONUtil.toJsonStr(fileDTOList));
platformService.uploadPlatform(files, request);
}
});
}
/** /**
* *
* *
@ -148,8 +211,8 @@ public class OcrFileInfoServiceImpl implements IOcrFileInfoService {
* @return * @return
*/ */
@Override @Override
public int delete(DeleteOcrFileInfoDTO deleteOcrFileInfoDTO) { public int delete(String pid) {
return iOcrFileInfoDao.delete(deleteOcrFileInfoDTO.getIds()); return iOcrFileInfoDao.delete(pid);
} }
} }

@ -130,17 +130,9 @@ public class OcrRuleServiceImpl implements IOcrRuleService {
score = ocrRuleSecondJson.getMatchRatio(); score = ocrRuleSecondJson.getMatchRatio();
for (int j = 0; j < keyWordList.length; j++) { for (int j = 0; j < keyWordList.length; j++) {
keyWord = keyWordList[j]; keyWord = keyWordList[j];
if (ocrText.contains(keyWord)) { for (String ocrContent : ocrTextList) {
rate = keyWord.length() / (double) ocrText.length() * 100; if (handleOcrText(assortId, assortName, score, keyWord, ocrRuleResult, ocrContent, ocrRule.getId()))
//判断是否命中
if (rate >= score) {
ocrRuleResult.setRuleId(ocrRule.getId());
ocrRuleResult.setAssortId(assortId);
ocrRuleResult.setAssortName(assortName);
ocrRuleResult.setHitKey(keyWord);
ocrRuleResult.setRate(rate);
return ocrRuleResult; return ocrRuleResult;
}
} }
} }
} }
@ -156,6 +148,23 @@ public class OcrRuleServiceImpl implements IOcrRuleService {
return null; return null;
} }
static boolean handleOcrText(String assortId, String assortName, double score, String keyWord, OcrRuleResult ocrRuleResult, String ocrContent, Long id ) {
double rate;
if (ocrContent.contains(keyWord)) {
rate = keyWord.length() / (double) ocrContent.length() * 100;
//判断是否命中
if (rate >= score) {
ocrRuleResult.setRuleId(id);
ocrRuleResult.setAssortId(assortId);
ocrRuleResult.setAssortName(assortName);
ocrRuleResult.setHitKey(keyWord);
ocrRuleResult.setRate(rate);
return true;
}
}
return false;
}
/** /**
* *
* *

@ -83,17 +83,9 @@ public class OcrRuleTestServiceImpl implements IOcrRuleTestService {
score = ocrRuleSecondJson.getMatchRatio(); score = ocrRuleSecondJson.getMatchRatio();
for (int j = 0; j < keyWordList.length; j++) { for (int j = 0; j < keyWordList.length; j++) {
keyWord = keyWordList[j]; keyWord = keyWordList[j];
if (ocrText.contains(keyWord)) { for (String ocrContent : ocrTextList) {
rate = keyWord.length() / (double) ocrText.length() * 100; if (OcrRuleServiceImpl.handleOcrText(assortId, assortName, score, keyWord, ocrRuleResult, ocrContent, ocrRuleTest.getId()))
//判断是否命中
if (rate >= score) {
ocrRuleResult.setRuleId(ocrRuleTest.getId());
ocrRuleResult.setAssortId(assortId);
ocrRuleResult.setAssortName(assortName);
ocrRuleResult.setHitKey(keyWord);
ocrRuleResult.setRate(rate);
return ocrRuleResult; return ocrRuleResult;
}
} }
} }
} }

@ -53,6 +53,7 @@ public class PlatformServiceImpl {
data.put("files", files.toArray(new File[files.size()])); data.put("files", files.toArray(new File[files.size()]));
data.put("patientId", request.getPatientId()); data.put("patientId", request.getPatientId());
data.put("fileInfo", request.getFileInfo()); data.put("fileInfo", request.getFileInfo());
data.put("collectorId", request.getCollectorId());
return uploadFile(data); return uploadFile(data);
} catch (Exception ex) { } catch (Exception ex) {
return CommonResult.failed(ex.getMessage()); return CommonResult.failed(ex.getMessage());

@ -28,8 +28,8 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
servlet: servlet:
multipart: multipart:
max-file-size: 100MB max-file-size: 1024MB
max-request-size: 200MB max-request-size: 1024MB
redis: redis:
host: redis.docus.cn host: redis.docus.cn
password: JSdocus@702 password: JSdocus@702
@ -66,6 +66,10 @@ file:
ocr: ocr:
api-url: http://192.168.16.85:9999/uploadfile api-url: http://192.168.16.85:9999/uploadfile
defaultAssortId: -1
defaultAssortName: 其他
defaultAssortSource: 3
defaultSuffix: (扫描)
download: download:
api-url: http://localhost:9291/api/downplatform/uploadFileBatch api-url: http://localhost:9291/api/downplatform/uploadFileBatch

@ -1,56 +1,56 @@
package com.docus.server; //package com.docus.server;
//
import oshi.SystemInfo; //import oshi.SystemInfo;
import oshi.hardware.CentralProcessor; //import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory; //import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer; //import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.NetworkIF; //import oshi.hardware.NetworkIF;
import oshi.software.os.FileSystem; //import oshi.software.os.FileSystem;
import oshi.software.os.OSFileStore; //import oshi.software.os.OSFileStore;
//
import java.util.Arrays; //import java.util.Arrays;
import java.util.List; //import java.util.List;
//
public class Example { //public class Example {
public static void main(String[] args) { // public static void main(String[] args) {
SystemInfo systemInfo = new SystemInfo(); // SystemInfo systemInfo = new SystemInfo();
CentralProcessor processor = systemInfo.getHardware().getProcessor(); // CentralProcessor processor = systemInfo.getHardware().getProcessor();
int logicalProcessorCount = processor.getLogicalProcessorCount(); // int logicalProcessorCount = processor.getLogicalProcessorCount();
String cpuModel = processor.getProcessorIdentifier().getName(); // String cpuModel = processor.getProcessorIdentifier().getName();
long[] systemCpuLoadTicks = processor.getSystemCpuLoadTicks(); // long[] systemCpuLoadTicks = processor.getSystemCpuLoadTicks();
//
System.out.println(logicalProcessorCount); // System.out.println(logicalProcessorCount);
System.out.println(cpuModel); // System.out.println(cpuModel);
System.out.println(Arrays.asList(systemCpuLoadTicks)); // System.out.println(Arrays.asList(systemCpuLoadTicks));
//
GlobalMemory memory = systemInfo.getHardware().getMemory(); // GlobalMemory memory = systemInfo.getHardware().getMemory();
long totalMemorySize = memory.getTotal(); // long totalMemorySize = memory.getTotal();
long availableMemorySize = memory.getAvailable(); // long availableMemorySize = memory.getAvailable();
double memoryUsage = (totalMemorySize - availableMemorySize) * 100.0 / totalMemorySize; // double memoryUsage = (totalMemorySize - availableMemorySize) * 100.0 / totalMemorySize;
System.out.println(totalMemorySize); // System.out.println(totalMemorySize);
System.out.println(availableMemorySize); // System.out.println(availableMemorySize);
System.out.println(memoryUsage); // System.out.println(memoryUsage);
//
HardwareAbstractionLayer hal = systemInfo.getHardware(); // HardwareAbstractionLayer hal = systemInfo.getHardware();
FileSystem fileSystem = systemInfo.getOperatingSystem().getFileSystem(); // FileSystem fileSystem = systemInfo.getOperatingSystem().getFileSystem();
List<OSFileStore> fileStores = fileSystem.getFileStores(); // List<OSFileStore> fileStores = fileSystem.getFileStores();
for (OSFileStore store : fileStores) { // for (OSFileStore store : fileStores) {
long totalSpace = store.getTotalSpace(); // long totalSpace = store.getTotalSpace();
long usableSpace = store.getUsableSpace(); // long usableSpace = store.getUsableSpace();
double usage = (totalSpace - usableSpace) * 100.0 / totalSpace; // double usage = (totalSpace - usableSpace) * 100.0 / totalSpace;
System.out.println(totalSpace); // System.out.println(totalSpace);
System.out.println(usableSpace); // System.out.println(usableSpace);
System.out.println(usage); // System.out.println(usage);
} // }
//
List<NetworkIF> networkIFs = systemInfo.getHardware().getNetworkIFs(); // List<NetworkIF> networkIFs = systemInfo.getHardware().getNetworkIFs();
for (NetworkIF networkIF : networkIFs) { // for (NetworkIF networkIF : networkIFs) {
String name = networkIF.getName(); // String name = networkIF.getName();
long receiveBytes = networkIF.getBytesRecv(); // long receiveBytes = networkIF.getBytesRecv();
long transmitBytes = networkIF.getBytesSent(); // long transmitBytes = networkIF.getBytesSent();
System.out.println(name); // System.out.println(name);
System.out.println(receiveBytes); // System.out.println(receiveBytes);
System.out.println(transmitBytes); // System.out.println(transmitBytes);
} // }
} // }
} //}

@ -1,83 +1,83 @@
package com.docus.server; //package com.docus.server;
//
import cn.hutool.core.util.ZipUtil; //import cn.hutool.core.util.ZipUtil;
import cn.hutool.http.HttpRequest; //import cn.hutool.http.HttpRequest;
//
import com.google.common.collect.Lists; //import com.google.common.collect.Lists;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.PostMapping;
//
import java.io.File; //import java.io.File;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.HashMap; //import java.util.HashMap;
import java.util.Map; //import java.util.Map;
//
/** ///**
* API // * 文件上传下载 API
* // *
* @author AutoGenerator // * @author AutoGenerator
* @since 2023-07-15 // * @since 2023-07-15
*/ // */
@SpringBootTest //@SpringBootTest
public class FileController { //public class FileController {
//
//
//
//
public static void test1() throws Exception { // public static void test1() throws Exception {
ZipUtil.unzip("/Users/linruifeng/Desktop/collector_packages/collector.zip", "/Users/linruifeng/Desktop/collector_packages"); // ZipUtil.unzip("/Users/linruifeng/Desktop/collector_packages/collector.zip", "/Users/linruifeng/Desktop/collector_packages");
// ZipUtil.unGzip(new GZIPInputStream(new FileInputStream(new File("/Users/linruifeng/Desktop/collector_packages/index.tar.gz")))); //// ZipUtil.unGzip(new GZIPInputStream(new FileInputStream(new File("/Users/linruifeng/Desktop/collector_packages/index.tar.gz"))));
// FileUtils.unTarGz("/Users/linruifeng/Desktop/collector_packages/", "/Users/linruifeng/Desktop/collector_packages/test"); //// FileUtils.unTarGz("/Users/linruifeng/Desktop/collector_packages/", "/Users/linruifeng/Desktop/collector_packages/test");
} // }
//
@ApiOperation("test") // @ApiOperation("test")
@PostMapping("/test") // @PostMapping("/test")
public void test2() throws Exception { // public void test2() throws Exception {
File file = new File("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg"); // File file = new File("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg");
File file1 = new File("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174052\\麻醉.jpg"); // File file1 = new File("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174052\\麻醉.jpg");
//
Map<String, Object> data = new HashMap<>(); // Map<String, Object> data = new HashMap<>();
data.put("files", file); // data.put("files", file);
data.put("filetype", "jpg"); // data.put("filetype", "jpg");
//
ArrayList<File> files = Lists.newArrayList(file, file1); // ArrayList<File> files = Lists.newArrayList(file, file1);
//
String body = HttpRequest.post("http://localhost:9115/file/upload") // String body = HttpRequest.post("http://localhost:9115/file/upload")
.form("files", files.toArray(new File[files.size()])) // .form("files", files.toArray(new File[files.size()]))
.form("pathKey", "{\n" + // .form("pathKey", "{\n" +
" \"success\": true,\n" + // " \"success\": true,\n" +
" \"datas\": [\n" + // " \"datas\": [\n" +
" {\n" + // " {\n" +
" \"index\": 0,\n" + // " \"index\": 0,\n" +
" \"file_type\": \"string\",\n" + // " \"file_type\": \"string\",\n" +
" \"angle\": \"string\",\n" + // " \"angle\": \"string\",\n" +
" \"decline\": true,\n" + // " \"decline\": true,\n" +
" \"hand_shadow\": true,\n" + // " \"hand_shadow\": true,\n" +
" \"sort\": [\n" + // " \"sort\": [\n" +
" \"string\"\n" + // " \"string\"\n" +
" ],\n" + // " ],\n" +
" \"data\": [\n" + // " \"data\": [\n" +
" {\n" + // " {\n" +
" \"boxes\": {\n" + // " \"boxes\": {\n" +
" \"left\": 0,\n" + // " \"left\": 0,\n" +
" \"right\": 0,\n" + // " \"right\": 0,\n" +
" \"top\": 0,\n" + // " \"top\": 0,\n" +
" \"bottom\": 0\n" + // " \"bottom\": 0\n" +
" },\n" + // " },\n" +
" \"text\": \"string\"\n" + // " \"text\": \"string\"\n" +
" }\n" + // " }\n" +
" ]\n" + // " ]\n" +
" }\n" + // " }\n" +
" ],\n" + // " ],\n" +
" \"time\": 0,\n" + // " \"time\": 0,\n" +
" \"message\": \"string\"\n" + // " \"message\": \"string\"\n" +
"}") // "}")
.contentType("multipart/form-data") // .contentType("multipart/form-data")
.execute() // .execute()
.body(); // .body();
//
System.out.println(body); // System.out.println(body);
//
} // }
} //}

@ -1,162 +1,162 @@
package com.docus.server; //package com.docus.server;
//
import org.apache.tools.tar.TarInputStream; //import org.apache.tools.tar.TarInputStream;
//
import java.io.*; //import java.io.*;
import java.util.zip.GZIPInputStream; //import java.util.zip.GZIPInputStream;
//
/** ///**
* @program: JavaCode // * @program: JavaCode
* @ClassName FileUtils // * @ClassName FileUtils
* @description: // * @description:
* @author: ltcz99 // * @author: ltcz99
* @create: 2023-04-16 // * @create: 2023-04-16
* @Version 1.0 // * @Version 1.0
**/ // **/
public class FileUtils { //public class FileUtils {
//
//
/** // /**
* tar.gz // * 解压tar.gz文件到指定目录
* // *
* @param sourceDir // * @param sourceDir 源文件夹
* @param destDir // * @param destDir 解压后的目标文件夹
*/ // */
public static void unTarGz(String sourceDir, String destDir) throws Exception { // public static void unTarGz(String sourceDir, String destDir) throws Exception {
File outFile = new File(sourceDir); // File outFile = new File(sourceDir);
File[] files = outFile.listFiles(); // File[] files = outFile.listFiles();
try { // try {
//创建输出目录 // //创建输出目录
createDirectory(destDir, null); // createDirectory(destDir, null);
TarInputStream tarIn; // TarInputStream tarIn;
int index = 1; // int index = 1;
for (File file : files) { // for (File file : files) {
if (file.getName().contains("tar.gz")) { // if (file.getName().contains("tar.gz")) {
tarIn = new TarInputStream(new GZIPInputStream( // tarIn = new TarInputStream(new GZIPInputStream(
new BufferedInputStream(new FileInputStream(file))), // new BufferedInputStream(new FileInputStream(file))),
1024 * 2); // 1024 * 2);
//
String outFileName = destDir + "/" + file.getName(); // String outFileName = destDir + "/" + file.getName();
OutputStream out = new FileOutputStream(new File(outFileName)); // OutputStream out = new FileOutputStream(new File(outFileName));
int length = 0; // int length = 0;
byte[] b = new byte[2048]; // byte[] b = new byte[2048];
while ((length = tarIn.read(b)) != -1) { // while ((length = tarIn.read(b)) != -1) {
out.write(b, 0, length); // out.write(b, 0, length);
} // }
out.close(); // out.close();
tarIn.close(); // tarIn.close();
} // }
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//
} // }
//
/** // /**
* gz // * 解压gz到指定的文件夹下面
* // *
* @param sourceDir // * @param sourceDir
* @param destDir // * @param destDir
*/ // */
public static void unGzipFile(String sourceDir, String destDir) { // public static void unGzipFile(String sourceDir, String destDir) {
//创建输出目录 // //创建输出目录
createDirectory(destDir, null); // createDirectory(destDir, null);
File sourceFile = new File(sourceDir); // File sourceFile = new File(sourceDir);
File[] files = sourceFile.listFiles(); // File[] files = sourceFile.listFiles();
try { // try {
int index = 1; // int index = 1;
for (File file : files) { // for (File file : files) {
if (file.getName().contains("gz")) { // if (file.getName().contains("gz")) {
FileInputStream fin = new FileInputStream(file); // FileInputStream fin = new FileInputStream(file);
//建立gzip解压工作流 // //建立gzip解压工作流
GZIPInputStream gzin = new GZIPInputStream(fin); // GZIPInputStream gzin = new GZIPInputStream(fin);
//建立解压文件输出流 // //建立解压文件输出流
File tmpFile = new File(destDir + "/" + index++ + ".log"); // File tmpFile = new File(destDir + "/" + index++ + ".log");
FileOutputStream fout = new FileOutputStream(tmpFile); // FileOutputStream fout = new FileOutputStream(tmpFile);
int length; // int length;
byte[] buf = new byte[2048]; // byte[] buf = new byte[2048];
while ((length = gzin.read(buf, 0, buf.length)) != -1) { // while ((length = gzin.read(buf, 0, buf.length)) != -1) {
fout.write(buf, 0, length); // fout.write(buf, 0, length);
} // }
gzin.close(); // gzin.close();
fout.close(); // fout.close();
fin.close(); // fin.close();
} // }
} // }
} catch (Exception ex) { // } catch (Exception ex) {
System.err.println(ex); // System.err.println(ex);
} // }
} // }
//
/** // /**
* // * 读取文件到指定的文件夹下面
* // *
* @param sourceLogPath // * @param sourceLogPath
* @param destLogPath // * @param destLogPath
*/ // */
public static void readFileToDestLogPath(String sourceLogPath, String destLogPath) { // public static void readFileToDestLogPath(String sourceLogPath, String destLogPath) {
File sourceFile = new File(sourceLogPath); // File sourceFile = new File(sourceLogPath);
File[] files = sourceFile.listFiles(); // File[] files = sourceFile.listFiles();
for (File file : files) { // for (File file : files) {
String fileName = destLogPath + "/" + file.getName(); // String fileName = destLogPath + "/" + file.getName();
File destFile = new File(fileName); // File destFile = new File(fileName);
if (file.getName().contains("log") && !fileName.contains("gz")) { // if (file.getName().contains("log") && !fileName.contains("gz")) {
try { // try {
if (destFile.exists()) { // if (destFile.exists()) {
destFile.delete(); // destFile.delete();
} // }
String logFile = sourceFile + "/" + file.getName(); // String logFile = sourceFile + "/" + file.getName();
FileInputStream fis = new FileInputStream(logFile); // FileInputStream fis = new FileInputStream(logFile);
FileOutputStream fos = new FileOutputStream(destFile); // FileOutputStream fos = new FileOutputStream(destFile);
BufferedInputStream bis = new BufferedInputStream(fis); // BufferedInputStream bis = new BufferedInputStream(fis);
BufferedOutputStream bos = new BufferedOutputStream(fos); // BufferedOutputStream bos = new BufferedOutputStream(fos);
int len = 0; // int len = 0;
while ((len = bis.read()) != -1) { // while ((len = bis.read()) != -1) {
bos.write(len); // bos.write(len);
} // }
bos.flush(); // bos.flush();
// 关闭资源 // // 关闭资源
fis.close(); // fis.close();
bis.close(); // bis.close();
fos.close(); // fos.close();
bos.close(); // bos.close();
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
} // }
//
} // }
//
/** // /**
* // * 创建目录
* // *
* @param outputDir // * @param outputDir
* @param subDir // * @param subDir
*/ // */
public static void createDirectory(String outputDir, String subDir) { // public static void createDirectory(String outputDir, String subDir) {
File file = new File(outputDir); // File file = new File(outputDir);
//子目录不为空 // //子目录不为空
if (!(subDir == null || subDir.trim().equals(""))) { // if (!(subDir == null || subDir.trim().equals(""))) {
file = new File(outputDir + "/" + subDir); // file = new File(outputDir + "/" + subDir);
} // }
if (!file.exists()) { // if (!file.exists()) {
if (!file.getParentFile().exists()) { // if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); // file.getParentFile().mkdirs();
} // }
file.mkdirs(); // file.mkdirs();
} // }
} // }
//
public static void main(String[] args) throws Exception { // public static void main(String[] args) throws Exception {
String sourceDir = "/Users/ltcz99/Downloads/templog"; // String sourceDir = "/Users/ltcz99/Downloads/templog";
String destDir = "/Users/ltcz99/Downloads/unzip/"; // String destDir = "/Users/ltcz99/Downloads/unzip/";
//解压.gz文件到指定的文件件下面 // //解压.gz文件到指定的文件件下面
unGzipFile(sourceDir, destDir); // unGzipFile(sourceDir, destDir);
// 解压tar.gz文件到指定的文件夹下面 // // 解压tar.gz文件到指定的文件夹下面
unTarGz(sourceDir, destDir); // unTarGz(sourceDir, destDir);
//读取特定的文件到指定的文件夹下面 // //读取特定的文件到指定的文件夹下面
readFileToDestLogPath(sourceDir, destDir); // readFileToDestLogPath(sourceDir, destDir);
} // }
} //}

@ -1,60 +1,60 @@
package com.docus.server; //package com.docus.server;
//
import cn.hutool.core.img.ImgUtil; //import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil; //import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; //import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; //import cn.hutool.http.HttpRequest;
//
import java.io.File; //import java.io.File;
import java.util.HashMap; //import java.util.HashMap;
import java.util.Map; //import java.util.Map;
//
public class ImageProcessingExample { //public class ImageProcessingExample {
//
public static void main(String[] args) throws Exception { // public static void main(String[] args) throws Exception {
//
// UploadBatchFileRequest uploadBatchFileParam = new UploadBatchFileRequest(); //// UploadBatchFileRequest uploadBatchFileParam = new UploadBatchFileRequest();
// System.out.println(JSON.toJSON(uploadBatchFileParam)); //// System.out.println(JSON.toJSON(uploadBatchFileParam));
// ////
// FileDTO fileDto = new FileDTO(); //// FileDTO fileDto = new FileDTO();
// System.out.println(JSON.toJSON(fileDto)); //// System.out.println(JSON.toJSON(fileDto));
// ////
// List<FileDTO> fileDtoList = new ArrayList<>(); //// List<FileDTO> fileDtoList = new ArrayList<>();
// System.out.println(JSON.toJSON(fileDtoList)); //// System.out.println(JSON.toJSON(fileDtoList));
//
//
// 1. 调整图片大小 // // 1. 调整图片大小
ImgUtil.scale(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg"), FileUtil.file("C:\\Users\\dataexa\\Desktop\\output-麻醉.jpg"), 0.5f); // ImgUtil.scale(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg"), FileUtil.file("C:\\Users\\dataexa\\Desktop\\output-麻醉.jpg"), 0.5f);
//
// 2. 裁剪图片 // // 2. 裁剪图片
// ImgUtil.cut(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg"), FileUtil.file("C:\\Users\\dataexa\\Desktop\\output1.jpg"), new Rectangle(50, 50, 2400, (3527 / 2) / 2)); // 从input.jpg中裁剪出一个200x200的区域保存为output.jpg //// ImgUtil.cut(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg"), FileUtil.file("C:\\Users\\dataexa\\Desktop\\output1.jpg"), new Rectangle(50, 50, 2400, (3527 / 2) / 2)); // 从input.jpg中裁剪出一个200x200的区域保存为output.jpg
//
// 5. 图片旋转 // // 5. 图片旋转
// Image image = ImgUtil.rotate(ImageIO.read(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg")), 90); //// Image image = ImgUtil.rotate(ImageIO.read(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg")), 90);
// ImgUtil.write(image, FileUtil.file("C:\\Users\\dataexa\\Desktop\\output2.jpg")); //// ImgUtil.write(image, FileUtil.file("C:\\Users\\dataexa\\Desktop\\output2.jpg"));
//
// uploadByte("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg"); //// uploadByte("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg");
} // }
//
public static void uploadByte(String path) { // public static void uploadByte(String path) {
File toFile = new File(path); // File toFile = new File(path);
Map data = new HashMap(); // Map data = new HashMap();
data.put("file", toFile); // data.put("file", toFile);
data.put("filetype", "jpg"); // data.put("filetype", "jpg");
String body = HttpRequest.post("http://192.168.16.85:9999/uploadfile") // String body = HttpRequest.post("http://192.168.16.85:9999/uploadfile")
.form(data) // .form(data)
.contentType("multipart/form-data") // .contentType("multipart/form-data")
.execute() // .execute()
.body(); // .body();
if (StrUtil.isNotBlank(body)) { // if (StrUtil.isNotBlank(body)) {
// OcrResponse jsonRootBean = JSON.parseObject(body, OcrResponse.class); //// OcrResponse jsonRootBean = JSON.parseObject(body, OcrResponse.class);
// System.out.println(jsonRootBean); //// System.out.println(jsonRootBean);
} // }
//
// Boolean success = (Boolean)result.get("success"); //// Boolean success = (Boolean)result.get("success");
// BigDecimal time = (BigDecimal)result.get("time"); //// BigDecimal time = (BigDecimal)result.get("time");
//
} // }
//
//
} //}

@ -1,313 +1,313 @@
package com.docus.server; //package com.docus.server;
//
import com.alibaba.fastjson.JSONArray; //import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import oshi.SystemInfo; //import oshi.SystemInfo;
import oshi.hardware.CentralProcessor; //import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory; //import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer; //import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.NetworkIF; //import oshi.hardware.NetworkIF;
import oshi.software.os.FileSystem; //import oshi.software.os.FileSystem;
import oshi.software.os.OSFileStore; //import oshi.software.os.OSFileStore;
import oshi.software.os.OperatingSystem; //import oshi.software.os.OperatingSystem;
import oshi.util.Util; //import oshi.util.Util;
//
import java.io.BufferedReader; //import java.io.BufferedReader;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStreamReader; //import java.io.InputStreamReader;
import java.net.InetAddress; //import java.net.InetAddress;
import java.net.UnknownHostException; //import java.net.UnknownHostException;
import java.text.DecimalFormat; //import java.text.DecimalFormat;
import java.util.Formatter; //import java.util.Formatter;
import java.util.HashMap; //import java.util.HashMap;
import java.util.List; //import java.util.List;
import java.util.Map; //import java.util.Map;
import java.util.Optional; //import java.util.Optional;
import java.util.Properties; //import java.util.Properties;
import java.util.StringTokenizer; //import java.util.StringTokenizer;
//
/** ///**
* // * 系统消息工具类
**/ // **/
public class SystemInfoUtils { //public class SystemInfoUtils {
//
private static final int OSHI_WAIT_SECOND = 1000; // private static final int OSHI_WAIT_SECOND = 1000;
private static final int SLEEP_TIME = 2 * 1000; // private static final int SLEEP_TIME = 2 * 1000;
private static SystemInfo systemInfo = new SystemInfo(); // private static SystemInfo systemInfo = new SystemInfo();
private static HardwareAbstractionLayer hardware = systemInfo.getHardware(); // private static HardwareAbstractionLayer hardware = systemInfo.getHardware();
private static OperatingSystem operatingSystem = systemInfo.getOperatingSystem(); // private static OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
//
public static void main(String[] args) throws Exception { // public static void main(String[] args) throws Exception {
JSONObject info = getInfo(); // JSONObject info = getInfo();
System.out.println(info); // System.out.println(info);
} // }
//
public static JSONObject getCpuInfo() { // public static JSONObject getCpuInfo() {
JSONObject cpuInfo = new JSONObject(); // JSONObject cpuInfo = new JSONObject();
CentralProcessor processor = hardware.getProcessor(); // CentralProcessor processor = hardware.getProcessor();
// CPU信息 // // CPU信息
long[] prevTicks = processor.getSystemCpuLoadTicks(); // long[] prevTicks = processor.getSystemCpuLoadTicks();
Util.sleep(OSHI_WAIT_SECOND); // Util.sleep(OSHI_WAIT_SECOND);
long[] ticks = processor.getSystemCpuLoadTicks(); // long[] ticks = processor.getSystemCpuLoadTicks();
long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; // long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; // long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; // long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; // long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; // long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; // long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; // long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; // long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; // long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
//cpu核数 // //cpu核数
cpuInfo.put("cpuNum", processor.getLogicalProcessorCount()); // cpuInfo.put("cpuNum", processor.getLogicalProcessorCount());
//cpu系统使用率 // //cpu系统使用率
cpuInfo.put("cSys", new DecimalFormat("#.##%").format(cSys * 1.0 / totalCpu)); // cpuInfo.put("cSys", new DecimalFormat("#.##%").format(cSys * 1.0 / totalCpu));
//cpu用户使用率 // //cpu用户使用率
cpuInfo.put("user", new DecimalFormat("#.##%").format(user * 1.0 / totalCpu)); // cpuInfo.put("user", new DecimalFormat("#.##%").format(user * 1.0 / totalCpu));
//cpu当前等待率 // //cpu当前等待率
cpuInfo.put("iowait", new DecimalFormat("#.##%").format(iowait * 1.0 / totalCpu)); // cpuInfo.put("iowait", new DecimalFormat("#.##%").format(iowait * 1.0 / totalCpu));
//cpu当前使用率 // //cpu当前使用率
cpuInfo.put("idle", new DecimalFormat("#.##%").format(1.0 - (idle * 1.0 / totalCpu))); // cpuInfo.put("idle", new DecimalFormat("#.##%").format(1.0 - (idle * 1.0 / totalCpu)));
return cpuInfo; // return cpuInfo;
} // }
//
/** // /**
* jvm // * 系统jvm信息
*/ // */
public static JSONObject getJvmInfo() { // public static JSONObject getJvmInfo() {
JSONObject cpuInfo = new JSONObject(); // JSONObject cpuInfo = new JSONObject();
Properties props = System.getProperties(); // Properties props = System.getProperties();
Runtime runtime = Runtime.getRuntime(); // Runtime runtime = Runtime.getRuntime();
long jvmTotalMemoryByte = runtime.totalMemory(); // long jvmTotalMemoryByte = runtime.totalMemory();
long freeMemoryByte = runtime.freeMemory(); // long freeMemoryByte = runtime.freeMemory();
//jvm总内存 // //jvm总内存
cpuInfo.put("total", formatByte(runtime.totalMemory())); // cpuInfo.put("total", formatByte(runtime.totalMemory()));
//空闲空间 // //空闲空间
cpuInfo.put("free", formatByte(runtime.freeMemory())); // cpuInfo.put("free", formatByte(runtime.freeMemory()));
//jvm最大可申请 // //jvm最大可申请
cpuInfo.put("max", formatByte(runtime.maxMemory())); // cpuInfo.put("max", formatByte(runtime.maxMemory()));
//vm已使用内存 // //vm已使用内存
cpuInfo.put("user", formatByte(jvmTotalMemoryByte - freeMemoryByte)); // cpuInfo.put("user", formatByte(jvmTotalMemoryByte - freeMemoryByte));
//jvm内存使用率 // //jvm内存使用率
cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((jvmTotalMemoryByte - freeMemoryByte) * 1.0 / jvmTotalMemoryByte)); // cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((jvmTotalMemoryByte - freeMemoryByte) * 1.0 / jvmTotalMemoryByte));
//jdk版本 // //jdk版本
cpuInfo.put("jdkVersion", props.getProperty("java.version")); // cpuInfo.put("jdkVersion", props.getProperty("java.version"));
//jdk路径 // //jdk路径
cpuInfo.put("jdkHome", props.getProperty("java.home")); // cpuInfo.put("jdkHome", props.getProperty("java.home"));
return cpuInfo; // return cpuInfo;
} // }
//
/** // /**
* // * 系统内存信息
*/ // */
public static JSONObject getMemInfo() { // public static JSONObject getMemInfo() {
JSONObject cpuInfo = new JSONObject(); // JSONObject cpuInfo = new JSONObject();
GlobalMemory memory = systemInfo.getHardware().getMemory(); // GlobalMemory memory = systemInfo.getHardware().getMemory();
//总内存 // //总内存
long totalByte = memory.getTotal(); // long totalByte = memory.getTotal();
//剩余 // //剩余
long acaliableByte = memory.getAvailable(); // long acaliableByte = memory.getAvailable();
//总内存 // //总内存
cpuInfo.put("total", formatByte(totalByte)); // cpuInfo.put("total", formatByte(totalByte));
//使用 // //使用
cpuInfo.put("used", formatByte(totalByte - acaliableByte)); // cpuInfo.put("used", formatByte(totalByte - acaliableByte));
//剩余内存 // //剩余内存
cpuInfo.put("free", formatByte(acaliableByte)); // cpuInfo.put("free", formatByte(acaliableByte));
//使用率 // //使用率
cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((totalByte - acaliableByte) * 1.0 / totalByte)); // cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((totalByte - acaliableByte) * 1.0 / totalByte));
return cpuInfo; // return cpuInfo;
} // }
//
/** // /**
* // * 带宽
*/ // */
public static JSONArray networkIFs() throws Exception { // public static JSONArray networkIFs() throws Exception {
JSONObject cpuInfo; // JSONObject cpuInfo;
JSONArray sysFiles = new JSONArray(); // JSONArray sysFiles = new JSONArray();
//
List<NetworkIF> networkIFs = systemInfo.getHardware().getNetworkIFs(); // List<NetworkIF> networkIFs = systemInfo.getHardware().getNetworkIFs();
for (NetworkIF networkIF : networkIFs) { // for (NetworkIF networkIF : networkIFs) {
String name = networkIF.getName(); // String name = networkIF.getName();
long receiveBytes = networkIF.getBytesRecv(); // long receiveBytes = networkIF.getBytesRecv();
long transmitBytes = networkIF.getBytesSent(); // long transmitBytes = networkIF.getBytesSent();
//
cpuInfo = new JSONObject(); // cpuInfo = new JSONObject();
//名称 // //名称
cpuInfo.put("name", name); // cpuInfo.put("name", name);
//网络接收 // //网络接收
cpuInfo.put("receiveBytes", formatNumber(receiveBytes / (1024.0 * (2 * 1000 / 1000)))); // cpuInfo.put("receiveBytes", formatNumber(receiveBytes / (1024.0 * (2 * 1000 / 1000))));
//网络发送 // //网络发送
cpuInfo.put("transmitBytes", formatNumber(transmitBytes / (1024.0 * (2 * 1000 / 1000)))); // cpuInfo.put("transmitBytes", formatNumber(transmitBytes / (1024.0 * (2 * 1000 / 1000))));
//
sysFiles.add(cpuInfo); // sysFiles.add(cpuInfo);
} // }
return sysFiles; // return sysFiles;
} // }
//
public static JSONObject getNetWork() { // public static JSONObject getNetWork() {
JSONObject networkInfo = new JSONObject(); // JSONObject networkInfo = new JSONObject();
Properties props = System.getProperties(); // Properties props = System.getProperties();
String os = props.getProperty("os.name").toLowerCase(); // String os = props.getProperty("os.name").toLowerCase();
os = os.startsWith("win") ? "windows" : "linux"; // os = os.startsWith("win") ? "windows" : "linux";
Map<String, String> result = new HashMap<>(); // Map<String, String> result = new HashMap<>();
Process pro = null; // Process pro = null;
Runtime r = Runtime.getRuntime(); // Runtime r = Runtime.getRuntime();
BufferedReader input = null; // BufferedReader input = null;
try { // try {
String command = "windows".equals(os) ? "netstat -e" : "ifconfig"; // String command = "windows".equals(os) ? "netstat -e" : "ifconfig";
pro = r.exec(command); // pro = r.exec(command);
input = new BufferedReader(new InputStreamReader(pro.getInputStream())); // input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
long result1[] = readInLine(input, os); // long result1[] = readInLine(input, os);
Thread.sleep(SLEEP_TIME); // Thread.sleep(SLEEP_TIME);
pro.destroy(); // pro.destroy();
input.close(); // input.close();
pro = r.exec(command); // pro = r.exec(command);
input = new BufferedReader(new InputStreamReader(pro.getInputStream())); // input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
long result2[] = readInLine(input, os); // long result2[] = readInLine(input, os);
String rxPercent = formatNumber((result2[0] - result1[0]) / (1024.0 * (SLEEP_TIME / 1000)));// 下行速率(kB/s) // String rxPercent = formatNumber((result2[0] - result1[0]) / (1024.0 * (SLEEP_TIME / 1000)));// 下行速率(kB/s)
String txPercent = formatNumber((result2[1] - result1[1]) / (1024.0 * (SLEEP_TIME / 1000)));// 上行速率(kB/s) // String txPercent = formatNumber((result2[1] - result1[1]) / (1024.0 * (SLEEP_TIME / 1000)));// 上行速率(kB/s)
networkInfo.put("rxPercent", rxPercent); // networkInfo.put("rxPercent", rxPercent);
networkInfo.put("txPercent", txPercent); // networkInfo.put("txPercent", txPercent);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} finally { // } finally {
if (input != null) { // if (input != null) {
try { // try {
input.close(); // input.close();
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
Optional.ofNullable(pro).ifPresent(p -> p.destroy()); // Optional.ofNullable(pro).ifPresent(p -> p.destroy());
} // }
return networkInfo; // return networkInfo;
} // }
//
private static long[] readInLine(BufferedReader input, String osType) { // private static long[] readInLine(BufferedReader input, String osType) {
long arr[] = new long[2]; // long arr[] = new long[2];
StringTokenizer tokenStat = null; // StringTokenizer tokenStat = null;
try { // try {
if (osType.equals("linux")) { // 获取linux环境下的网口上下行速率 // if (osType.equals("linux")) { // 获取linux环境下的网口上下行速率
long rx = 0, tx = 0; // long rx = 0, tx = 0;
String line = null; // String line = null;
//RX packets:4171603 errors:0 dropped:0 overruns:0 frame:0 // //RX packets:4171603 errors:0 dropped:0 overruns:0 frame:0
//TX packets:4171603 errors:0 dropped:0 overruns:0 carrier:0 // //TX packets:4171603 errors:0 dropped:0 overruns:0 carrier:0
while ((line = input.readLine()) != null) { // while ((line = input.readLine()) != null) {
if (line.indexOf("RX packets") >= 0) { // if (line.indexOf("RX packets") >= 0) {
rx += Long.parseLong(line.substring(line.indexOf("RX packets") + 11, line.indexOf(" ", line.indexOf("RX packets") + 11))); // rx += Long.parseLong(line.substring(line.indexOf("RX packets") + 11, line.indexOf(" ", line.indexOf("RX packets") + 11)));
} else if (line.indexOf("TX packets") >= 0) { // } else if (line.indexOf("TX packets") >= 0) {
tx += Long.parseLong(line.substring(line.indexOf("TX packets") + 11, line.indexOf(" ", line.indexOf("TX packets") + 11))); // tx += Long.parseLong(line.substring(line.indexOf("TX packets") + 11, line.indexOf(" ", line.indexOf("TX packets") + 11)));
} // }
} // }
arr[0] = rx; // arr[0] = rx;
arr[1] = tx; // arr[1] = tx;
} else { // 获取windows环境下的网口上下行速率 // } else { // 获取windows环境下的网口上下行速率
input.readLine(); // input.readLine();
input.readLine(); // input.readLine();
input.readLine(); // input.readLine();
input.readLine(); // input.readLine();
tokenStat = new StringTokenizer(input.readLine()); // tokenStat = new StringTokenizer(input.readLine());
tokenStat.nextToken(); // tokenStat.nextToken();
arr[0] = Long.parseLong(tokenStat.nextToken()); // arr[0] = Long.parseLong(tokenStat.nextToken());
arr[1] = Long.parseLong(tokenStat.nextToken()); // arr[1] = Long.parseLong(tokenStat.nextToken());
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return arr; // return arr;
} // }
//
//
private static String formatNumber(double f) { // private static String formatNumber(double f) {
return new Formatter().format("%.2f", f).toString(); // return new Formatter().format("%.2f", f).toString();
} // }
//
/** // /**
* // * 系统盘符信息
*/ // */
public static JSONArray getSysFileInfo() { // public static JSONArray getSysFileInfo() {
JSONObject cpuInfo; // JSONObject cpuInfo;
JSONArray sysFiles = new JSONArray(); // JSONArray sysFiles = new JSONArray();
FileSystem fileSystem = operatingSystem.getFileSystem(); // FileSystem fileSystem = operatingSystem.getFileSystem();
List<OSFileStore> fsArray = fileSystem.getFileStores(); // List<OSFileStore> fsArray = fileSystem.getFileStores();
for (OSFileStore fs : fsArray) { // for (OSFileStore fs : fsArray) {
cpuInfo = new JSONObject(); // cpuInfo = new JSONObject();
//盘符路径 // //盘符路径
cpuInfo.put("dirName", fs.getMount()); // cpuInfo.put("dirName", fs.getMount());
//盘符类型 // //盘符类型
cpuInfo.put("sysTypeName", fs.getType()); // cpuInfo.put("sysTypeName", fs.getType());
//文件类型 // //文件类型
cpuInfo.put("typeName", fs.getName()); // cpuInfo.put("typeName", fs.getName());
//总大小 // //总大小
cpuInfo.put("total", formatByte(fs.getTotalSpace())); // cpuInfo.put("total", formatByte(fs.getTotalSpace()));
//剩余大小 // //剩余大小
cpuInfo.put("free", formatByte(fs.getUsableSpace())); // cpuInfo.put("free", formatByte(fs.getUsableSpace()));
//已经使用量 // //已经使用量
cpuInfo.put("used", formatByte(fs.getTotalSpace() - fs.getUsableSpace())); // cpuInfo.put("used", formatByte(fs.getTotalSpace() - fs.getUsableSpace()));
if (fs.getTotalSpace() == 0) { // if (fs.getTotalSpace() == 0) {
//资源的使用率 // //资源的使用率
cpuInfo.put("usage", 0); // cpuInfo.put("usage", 0);
} else { // } else {
cpuInfo.put("usage", new DecimalFormat("#.##%").format((fs.getTotalSpace() - fs.getUsableSpace()) * 1.0 / fs.getTotalSpace())); // cpuInfo.put("usage", new DecimalFormat("#.##%").format((fs.getTotalSpace() - fs.getUsableSpace()) * 1.0 / fs.getTotalSpace()));
} // }
sysFiles.add(cpuInfo); // sysFiles.add(cpuInfo);
} // }
return sysFiles; // return sysFiles;
} // }
//
/** // /**
* // * 系统信息
*/ // */
public static JSONObject getSysInfo() throws UnknownHostException { // public static JSONObject getSysInfo() throws UnknownHostException {
JSONObject cpuInfo = new JSONObject(); // JSONObject cpuInfo = new JSONObject();
Properties props = System.getProperties(); // Properties props = System.getProperties();
//操作系统名 // //操作系统名
cpuInfo.put("osName", props.getProperty("os.name")); // cpuInfo.put("osName", props.getProperty("os.name"));
//系统架构 // //系统架构
cpuInfo.put("osArch", props.getProperty("os.arch")); // cpuInfo.put("osArch", props.getProperty("os.arch"));
//服务器名称 // //服务器名称
cpuInfo.put("computerName", InetAddress.getLocalHost().getHostName()); // cpuInfo.put("computerName", InetAddress.getLocalHost().getHostName());
//服务器Ip // //服务器Ip
cpuInfo.put("computerIp", InetAddress.getLocalHost().getHostAddress()); // cpuInfo.put("computerIp", InetAddress.getLocalHost().getHostAddress());
//项目路径 // //项目路径
cpuInfo.put("userDir", props.getProperty("user.dir")); // cpuInfo.put("userDir", props.getProperty("user.dir"));
return cpuInfo; // return cpuInfo;
} // }
//
//
/** // /**
* // * 所有系统信息
*/ // */
public static JSONObject getInfo() throws Exception { // public static JSONObject getInfo() throws Exception {
JSONObject info = new JSONObject(); // JSONObject info = new JSONObject();
info.put("cpuInfo", getCpuInfo()); // info.put("cpuInfo", getCpuInfo());
info.put("jvmInfo", getJvmInfo()); // info.put("jvmInfo", getJvmInfo());
info.put("memInfo", getMemInfo()); // info.put("memInfo", getMemInfo());
info.put("sysInfo", getSysInfo()); // info.put("sysInfo", getSysInfo());
info.put("sysFileInfo", getSysFileInfo()); // info.put("sysFileInfo", getSysFileInfo());
info.put("networkInfo", getNetWork()); // info.put("networkInfo", getNetWork());
return info; // return info;
} // }
//
/** // /**
* // * 单位转换
*/ // */
private static String formatByte(long byteNumber) { // private static String formatByte(long byteNumber) {
//换算单位 // //换算单位
double FORMAT = 1024.0; // double FORMAT = 1024.0;
double kbNumber = byteNumber / FORMAT; // double kbNumber = byteNumber / FORMAT;
if (kbNumber < FORMAT) { // if (kbNumber < FORMAT) {
return new DecimalFormat("#.##KB").format(kbNumber); // return new DecimalFormat("#.##KB").format(kbNumber);
} // }
double mbNumber = kbNumber / FORMAT; // double mbNumber = kbNumber / FORMAT;
if (mbNumber < FORMAT) { // if (mbNumber < FORMAT) {
return new DecimalFormat("#.##MB").format(mbNumber); // return new DecimalFormat("#.##MB").format(mbNumber);
} // }
double gbNumber = mbNumber / FORMAT; // double gbNumber = mbNumber / FORMAT;
if (gbNumber < FORMAT) { // if (gbNumber < FORMAT) {
return new DecimalFormat("#.##GB").format(gbNumber); // return new DecimalFormat("#.##GB").format(gbNumber);
} // }
double tbNumber = gbNumber / FORMAT; // double tbNumber = gbNumber / FORMAT;
return new DecimalFormat("#.##TB").format(tbNumber); // return new DecimalFormat("#.##TB").format(tbNumber);
} // }
} //}

@ -1,87 +1,87 @@
package com.docus.server; //package com.docus.server;
//
import cn.smallbun.screw.core.Configuration; //import cn.smallbun.screw.core.Configuration;
import cn.smallbun.screw.core.engine.EngineConfig; //import cn.smallbun.screw.core.engine.EngineConfig;
import cn.smallbun.screw.core.engine.EngineFileType; //import cn.smallbun.screw.core.engine.EngineFileType;
import cn.smallbun.screw.core.engine.EngineTemplateType; //import cn.smallbun.screw.core.engine.EngineTemplateType;
import cn.smallbun.screw.core.execute.DocumentationExecute; //import cn.smallbun.screw.core.execute.DocumentationExecute;
import cn.smallbun.screw.core.process.ProcessConfig; //import cn.smallbun.screw.core.process.ProcessConfig;
import com.docus.server.api.ocr.OcrApi; //import com.docus.server.api.ocr.OcrApi;
import com.docus.server.vo.ocr.OcrResponse; //import com.docus.server.vo.ocr.OcrResponse;
import com.zaxxer.hikari.HikariConfig; //import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource; //import com.zaxxer.hikari.HikariDataSource;
import org.junit.jupiter.api.Test; //import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext; //import org.springframework.context.ApplicationContext;
//
import javax.annotation.Resource; //import javax.annotation.Resource;
import javax.sql.DataSource; //import javax.sql.DataSource;
import java.io.File; //import java.io.File;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.HashMap; //import java.util.HashMap;
import java.util.Map; //import java.util.Map;
//
@SpringBootTest //@SpringBootTest
class ScrewTests { //class ScrewTests {
//
@Autowired // @Autowired
private ApplicationContext applicationContext; // private ApplicationContext applicationContext;
@Resource // @Resource
private OcrApi ocrApi; // private OcrApi ocrApi;
//
@Test // @Test
void test() { // void test() {
//
HikariConfig hikariConfig = new HikariConfig(); // HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver"); // hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://db.docus.cn:3306/docus-collector-scheduling?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai"); // hikariConfig.setJdbcUrl("jdbc:mysql://db.docus.cn:3306/docus-collector-scheduling?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai");
hikariConfig.setUsername("docus"); // hikariConfig.setUsername("docus");
hikariConfig.setPassword("docus702"); // hikariConfig.setPassword("docus702");
//设置可以获取tables remarks信息 // //设置可以获取tables remarks信息
hikariConfig.addDataSourceProperty("useInformationSchema", "true"); // hikariConfig.addDataSourceProperty("useInformationSchema", "true");
hikariConfig.setMinimumIdle(2); // hikariConfig.setMinimumIdle(2);
hikariConfig.setMaximumPoolSize(5); // hikariConfig.setMaximumPoolSize(5);
DataSource dataSource = new HikariDataSource(hikariConfig); // DataSource dataSource = new HikariDataSource(hikariConfig);
//
//生成文件配置 // //生成文件配置
EngineConfig engineConfig = EngineConfig // EngineConfig engineConfig = EngineConfig
.builder() // .builder()
//文件生成路径 // //文件生成路径
.fileOutputDir("h:\\file") // .fileOutputDir("h:\\file")
//打开目录 // //打开目录
.openOutputDir(false) // .openOutputDir(false)
//文件类型 // //文件类型
.fileType(EngineFileType.HTML) // .fileType(EngineFileType.HTML)
//生成模板实现 // //生成模板实现
.produceType(EngineTemplateType.freemarker) // .produceType(EngineTemplateType.freemarker)
.build(); // .build();
//配置想要生成的表 // //配置想要生成的表
ProcessConfig processConfig = ProcessConfig // ProcessConfig processConfig = ProcessConfig
.builder() // .builder()
//根据名称指定表生成 // //根据名称指定表生成
.designatedTableName(new ArrayList<>()) // .designatedTableName(new ArrayList<>())
//根据表前缀生成 // //根据表前缀生成
.designatedTablePrefix(new ArrayList<>()) // .designatedTablePrefix(new ArrayList<>())
//根据表后缀生成 // //根据表后缀生成
.designatedTableSuffix(new ArrayList<>()) // .designatedTableSuffix(new ArrayList<>())
//忽略表名 // //忽略表名
.ignoreTableName(new ArrayList<>()) // .ignoreTableName(new ArrayList<>())
//忽略表前缀 // //忽略表前缀
.ignoreTablePrefix(new ArrayList<>()) // .ignoreTablePrefix(new ArrayList<>())
//忽略表后缀 // //忽略表后缀
.ignoreTableSuffix(new ArrayList<>()) // .ignoreTableSuffix(new ArrayList<>())
.build(); // .build();
//生成文档配置 // //生成文档配置
Configuration configuration = Configuration.builder() // Configuration configuration = Configuration.builder()
.version("1.0.0") // .version("1.0.0")
.description("描述") // .description("描述")
.dataSource(dataSource) // .dataSource(dataSource)
.engineConfig(engineConfig) // .engineConfig(engineConfig)
.produceConfig(processConfig) // .produceConfig(processConfig)
.build(); // .build();
//
//生成 // //生成
new DocumentationExecute(configuration).execute(); // new DocumentationExecute(configuration).execute();
} // }
} //}

Loading…
Cancel
Save