11、将图片地址改成可配置文件

2、删除老代码
3、给清单新增页码功能,包括护理的,以及重症的
4、新增统一接口下载方式,统一协议为FTP,文件类型为pdf,账号密码都为common
master
leijx 5 years ago
parent bace7fcf7f
commit ce66fbac70

@ -1,134 +0,0 @@
package com.ann.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ann.entity.filing.MessageSubordinate;
import com.ann.entity.filing.dto.MessageDto;
import com.ann.entity.filing.dto.PatientMainDto;
import com.ann.entity.interfaceEntity.MessageLog;
import com.ann.entity.other.QuartzBean;
import com.ann.repository.MessageSubordinateRepository;
import com.ann.service.ArchiveDetailService;
import com.ann.utils.*;
import jcifs.smb.SmbFileInputStream;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.omg.SendingContext.RunTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import sun.net.ftp.FtpClient;
import java.io.*;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/18 10:47
*/
@Controller
@RequestMapping("/")
public class TestController {
@Autowired
private ArchiveDetailService archiveDetailService;
@Autowired
MessageSubordinateRepository messageSubordinateRepository;
@RequestMapping("/demo")
public String aa() {
return "demo";
}
@RequestMapping("/haha")
public String createJob(QuartzBean quartzBean) {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("http://localhost:8080/services/HomepageDictionary?wsdl");
Object[] objects = new Object[0];
// invoke("方法名",参数1,参数2,参数3....);
try {
objects = client.invoke("CheckData", "2b52c101-69d3-495c-94dc-1e3c47e61623");
} catch (Exception e) {
e.printStackTrace();
}
return objects[0].toString();
}
@RequestMapping("/xixi")
public String xixi() {
// 创建url地址
/*String address = "ftp://PTVIEW:MedExTech@10.6.0.65:10021/ecgdata/ECG/2019-07-24/MECGCAS1907240069_1.jpg";
address = address.substring(address.indexOf("/")+2,address.length());
// 10.6.0.65:10021/ecgdata/ECG/2019-07-24/MECGCAS1907240069_1.jpg
String ftpAccount = address.substring(0,address.indexOf("@"));
String[] split = ftpAccount.split(":");
address = address.substring(address.indexOf("@")+1,address.length());
String url = address.substring(0,address.indexOf(":"));
Integer port = 0;
if(address.indexOf(":") != -1 && address.indexOf("/") != -1 ){
port = Integer.parseInt(address.substring(address.indexOf(":")+1,address.indexOf("/")));
}
String path = address.substring(address.indexOf("/"),address.length());
*/
String address = "ftp://10.6.0.75/000/000568558/2/000568558000_2_麻醉_麻醉单_1_1.pdf";
//String address = "ftp://10.6.0.65:10021/ecgdata/ECG/2019-07-25/201907250940334102.pdf";
String temp = address;
address = address.substring(address.indexOf("/") + 2, address.length());
String url = address.substring(0, address.indexOf("/"));
String path = address.substring(address.indexOf("/"), address.length());
try {
FtpClient ftpClient = FtpUtils.connectFTP(url, 21, "mdsd", "mdsd");
// File pdfFile = FileUtils.createFile("pdfs","789","123456", "阿雷小猴子");
//FtpUtils.downloadFtp(temp,ftpClient,pdfFile);
} catch (Exception e) {
e.printStackTrace();
}
return "我是测试ftp的~~~~";
}
// @RequestMapping("/deleteDetail")
// public String deleteDetail() throws Exception{
// archiveDetailService.delete();
// return "成功";
// }
@ResponseBody
@RequestMapping("/test")
public String xixi1() {
archiveDetailService.test();
return "哈哈哈哈";
}
@ResponseBody
@RequestMapping("/updatePatient")
public String cc1(){
List<MessageSubordinate> haha = messageSubordinateRepository.findHaha();
for (MessageSubordinate messageSubordinate:
haha) {
String contentJson = messageSubordinate.getContentJson();
MessageLog messageLog = JSON.parseObject(contentJson, MessageLog.class);
if (messageLog != null) {
String outJson = messageLog.getOutJson();
if (outJson != null) {
MessageDto messageDto = JSON.parseObject(outJson, MessageDto.class);
String patientMainStr = JSON.toJSONString(new PatientMainDto(messageDto.getInpNo(), messageDto.getVisitId()), SerializerFeature.WriteMapNullValue);
}
}
}
return haha.size()+"";
}
}

@ -23,17 +23,17 @@ public class AliasName {
// 心电图报告单 59
public static final String EKG_REPORT = "59";
// 入院记录
public static final String ADMISSION_RECORD = "9";
// 出院记录
public static final String DISCHARGE_RECORD = "113";
// 转科记录
public static final String TRANSFER_RECORD = "114";
// // 入院记录
// public static final String ADMISSION_RECORD = "9";
//
// // 出院记录
// public static final String DISCHARGE_RECORD = "113";
//
// // 转科记录
// public static final String TRANSFER_RECORD = "114";
// 取消入院
public static final String CANCELLATION_DISCHARGE = "115";
// public static final String CANCELLATION_DISCHARGE = "115";
// 手麻
public static final String HANDNUMBNESS_REPORT = "117";
@ -42,7 +42,7 @@ public class AliasName {
public static final String ICU_REPORT = "121";
// 检查申请单
public static final String PARAMETER_EXAMAPPLY = "119";
// public static final String PARAMETER_EXAMAPPLY = "119";
// 输血单
public static final String BLOODAPPLY_REPORT = "120";
@ -51,16 +51,16 @@ public class AliasName {
public static final String PETCT_REPORT = "60";
// V6护理记录单
public static final String NURSING_RECORD_SHEET = "2";
// public static final String NURSING_RECORD_SHEET = "2";
// 病案首页
public static final String MEDICAL_RECORD_HOMEPAGE = "3";
// public static final String MEDICAL_RECORD_HOMEPAGE = "3";
// 评估护理单
public static final String ASSESSMENT_NURSING_LIST = "4";
// public static final String ASSESSMENT_NURSING_LIST = "4";
// 体温单
public static final String THERMOGRAM = "5";
// public static final String THERMOGRAM = "5";
// 检验申请单
//public static final String PARAMETER_EXAMAPPLY = "118";
@ -68,8 +68,8 @@ public class AliasName {
// 检验报告
public static final String INSPECTION_REPORT = "10";
// 扫描文件
public static final String SCANNING_FILE = "30";
// // 扫描文件
// public static final String SCANNING_FILE = "30";
// 20200701 长期医嘱
public static final String PRN = "122";

@ -44,6 +44,7 @@ public class ArchiveDetail {
private String sys;
private Integer pageNumber = 1;
/**
*
* 2019-9-4

@ -1,63 +0,0 @@
package com.ann.entity.filing;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
* @Description ArchiveMaster
* @Date 2019/7/9 10:07
* @Created by ljx
*/
@Data
@Entity
@Table(name = "archive_detail_20191202")
public class ArchiveDetail1 {
@Id
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
@GeneratedValue(generator = "system-uuid")
private String id;
private String pdfPath;
// -----------------------绑定关系
@Column(name = "masterid")
private String masterID;
@Column(name = "uploaddatetime")
private Date upLoadDateTime;
@Column(name = "assortid")
private String assortID;
private String source;
@Column(name = "subassort")
private String subAssort;
private String title;
private String flag = "0";
private String sys;
/**
*
* 2019-9-4
*/
private String applyId;
public ArchiveDetail1() {
}
public ArchiveDetail1(String masterID, Date upLoadDateTime, String assortID, String source, String applyId) {
this.masterID = masterID;
this.upLoadDateTime = upLoadDateTime;
this.assortID = assortID;
this.source = source;
this.applyId = applyId;
}
}

@ -1,24 +0,0 @@
package com.ann.entity.filing;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
*
* @Author: LeiJiaXin
* @Date: 2019/7/11 21:49
*/
@Data
@Table
@Entity
public class Queue {
@Id
private String id;
private String time;
}

@ -25,9 +25,9 @@ public class SchedulerAllJob {
*/
public void scheduleJobs() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
// scheduleJob1(scheduler);
// scheduleJob2(scheduler);
// scheduleJob3(scheduler);
scheduleJob1(scheduler);
scheduleJob2(scheduler);
scheduleJob3(scheduler);
scheduleJob4(scheduler);
}
@ -90,7 +90,7 @@ public class SchedulerAllJob {
private void scheduleJob4(Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = JobBuilder.newJob(ScheduledJob4.class).withIdentity("job4", "group1").build();
// 0 1-2 * * * ?
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/15 * * * * ?");
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0 */1 * * * ?");
// 每1分钟执行一次
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("job4", "group1").withSchedule(scheduleBuilder).build();
scheduler.scheduleJob(jobDetail, cronTrigger);

@ -1,28 +0,0 @@
package com.ann.job.config;
/**
*
*
* @Author: LeiJiaXin
* @Date: 2019/7/13 17:03
*/
//@Configuration
public class QuartzConfig {
// @Bean
// public JobDetail uploadTaskDetail() {
// // 创建工作
// return JobBuilder.newJob(MyTask.class).withIdentity("MyTask").storeDurably().build();
// }
//
// @Bean
// public Trigger uploadTaskTrigger() {
// //TODO 这里设定执行方式
// CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("*/10 * * * * ?");
// // 返回任务触发器
// return TriggerBuilder.newTrigger().forJob(uploadTaskDetail())
// .withIdentity("MyTask")
// .withSchedule(scheduleBuilder)
// .build();
// }
}

@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
* @Date: 2019/7/13 17:03
*/
@Component
public class QuartzConfig1 implements CommandLineRunner {
public class QuartzConfig implements CommandLineRunner {
@Autowired
public SchedulerAllJob scheduleJobs;

@ -1,27 +0,0 @@
package com.ann.repository;
import com.ann.entity.filing.ArchiveDetail;
import com.ann.entity.filing.ArchiveDetail1;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/12 9:10
*/
@Repository
public interface ArchiveDetail1Repository extends JpaRepository<ArchiveDetail1, String> {
// or Source = 'DoctorData' or AssortID = '117' or AssortID = '10' or AssortID = '60' or AssortID = '57' or AssortID = '52' or AssortID = '54' or AssortID = '59'
@Query(nativeQuery = true, value = "select * from archive_detail o where o.MasterID in (select id from archive_master m where m.dept_admission_to = '1040100'\n" +
"and m.admission_date_time < '2019-11-27 00:00:00.000' )")
public List<ArchiveDetail1> findAllHaha();
@Query("select count (o) from ArchiveDetail o where o.masterID = ?1 and o.assortID = ?2 and o.source=?3 and (o.applyId = ?4 and o.applyId is not null) ")
Integer countByMasterIDAndAssortIDAndSourceAndApplyId(String masterId, String AssortID, String source, String applyId);
public ArchiveDetail findByMasterIDAndAssortIDAndSourceAndApplyId(String masterId, String AssortID, String source, String applyId);
}

@ -14,9 +14,9 @@ import java.util.List;
@Repository
public interface ArchiveDetailRepository extends JpaRepository<ArchiveDetail, String> {
// or Source = 'DoctorData' or AssortID = '117' or AssortID = '10' or AssortID = '60' or AssortID = '57' or AssortID = '52' or AssortID = '54' or AssortID = '59'
@Query("select o from ArchiveDetail o ")
public List<ArchiveDetail> findAllHaha();
// // or Source = 'DoctorData' or AssortID = '117' or AssortID = '10' or AssortID = '60' or AssortID = '57' or AssortID = '52' or AssortID = '54' or AssortID = '59'
// @Query("select o from ArchiveDetail o ")
// public List<ArchiveDetail> findAllHaha();
@Query("select count (o) from ArchiveDetail o where o.masterID = ?1 and o.assortID = ?2 and o.source=?3 and (o.applyId = ?4 and o.applyId is not null) and o.flag = 0")
Integer countByMasterIDAndAssortIDAndSourceAndApplyId(String masterId, String AssortID, String source, String applyId);
@ -24,24 +24,24 @@ public interface ArchiveDetailRepository extends JpaRepository<ArchiveDetail, St
public ArchiveDetail findByMasterIDAndAssortIDAndSourceAndApplyIdAndFlag(String masterId, String AssortID, String source, String applyId,String flag);
@Query(value = "SELECT stuff(" +
" (SELECT ',' + CONVERT(VARCHAR,a.assort_name) " +
" FROM zd_assort a WHERE a.assort_id in ?1 " +
" and NOT EXISTS(SELECT id FROM archive_detail d WHERE a.assort_id = d.AssortID and d.MasterID = ?2 ) " +
" FOR XML PATH ('') " +
" ),1,1,'') ", nativeQuery = true)
String getTypeNotExits(List<String> type, String masterId);
@Query(value = "SELECT stuff(" +
" (SELECT ',' + CONVERT(VARCHAR,a.assort_name) " +
" FROM zd_assort a WHERE a.assort_id in ?1 " +
" and NOT EXISTS(SELECT id FROM archive_detail d WHERE a.assort_id = d.AssortID and d.MasterID = ?2 ) " +
" FOR XML PATH ('') " +
" ),1,1,'') ", nativeQuery = true)
String checkExamApply(String masterId);
@Query(value = " select * from archive_detail o where o.MasterID in (select m.ID from archive_master m where " +
" m.dept_name in(select code from emr_dictionary where name like ?1 ) and m.admission_Date_Time <= ?2 ) " +
" order by masterid,AssortID ",nativeQuery = true)
public List<ArchiveDetail> findArchiveDetail(String deptName,String admissionDateTime);
// @Query(value = "SELECT stuff(" +
// " (SELECT ',' + CONVERT(VARCHAR,a.assort_name) " +
// " FROM zd_assort a WHERE a.assort_id in ?1 " +
// " and NOT EXISTS(SELECT id FROM archive_detail d WHERE a.assort_id = d.AssortID and d.MasterID = ?2 ) " +
// " FOR XML PATH ('') " +
// " ),1,1,'') ", nativeQuery = true)
// String getTypeNotExits(List<String> type, String masterId);
// @Query(value = "SELECT stuff(" +
// " (SELECT ',' + CONVERT(VARCHAR,a.assort_name) " +
// " FROM zd_assort a WHERE a.assort_id in ?1 " +
// " and NOT EXISTS(SELECT id FROM archive_detail d WHERE a.assort_id = d.AssortID and d.MasterID = ?2 ) " +
// " FOR XML PATH ('') " +
// " ),1,1,'') ", nativeQuery = true)
// String checkExamApply(String masterId);
// @Query(value = " select * from archive_detail o where o.MasterID in (select m.ID from archive_master m where " +
// " m.dept_name in(select code from emr_dictionary where name like ?1 ) and m.admission_Date_Time <= ?2 ) " +
// " order by masterid,AssortID ",nativeQuery = true)
// public List<ArchiveDetail> findArchiveDetail(String deptName,String admissionDateTime);
}

@ -12,8 +12,4 @@ public interface InterfaceHisCacheRepository extends JpaRepository<InterfaceHisC
public List<InterfaceHisCache> findAllByStateAndPdfPathIsNotNull(String state);
// @Transactional
// @Modifying
// @Query(value = "update InterfaceHisCache o set o.state = ?1 where o.id = ?2 and o.state = 0 and o.type = ?3 ")
// public Integer updateStateById(Integer state, String id, Integer type);
}

@ -1,11 +0,0 @@
package com.ann.repository;
import com.ann.entity.filing.Queue;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/11 21:59
*/
public interface QueueRepository extends JpaRepository<Queue, String> {
}

@ -1,5 +1,6 @@
package com.ann.service;
import com.ann.entity.filing.ArchiveDetail;
import java.util.List;
@ -14,13 +15,10 @@ public interface ArchiveDetailService {
public void delete(String id) throws Exception;
public ArchiveDetail isExit(String id, String type, String source, String applyId) throws Exception;
public String getTypeNotExits(List<String> type, String masterId);
public String checkExamApply(String masterId) throws Exception;
// public String getTypeNotExits(List<String> type, String masterId);
// public String checkExamApply(String masterId) throws Exception;
public String test();
}

@ -1,8 +1,6 @@
package com.ann.service.impl;
import com.ann.entity.filing.ArchiveDetail;
import com.ann.entity.filing.ArchiveDetail1;
import com.ann.repository.ArchiveDetail1Repository;
import com.ann.repository.ArchiveDetailRepository;
import com.ann.service.ArchiveDetailService;
import com.ann.utils.FileUtils;
@ -22,8 +20,6 @@ public class ArchiveDetailServiceImpl implements ArchiveDetailService {
@Autowired
ArchiveDetailRepository archiveDetailRepository;
@Autowired
ArchiveDetail1Repository archiveDetail1Repository;
@Override
public void save(ArchiveDetail archiveDetail) throws Exception{
@ -43,29 +39,14 @@ public class ArchiveDetailServiceImpl implements ArchiveDetailService {
return null;
}
@Override
public String getTypeNotExits(List<String> type, String masterId) {
return archiveDetailRepository.getTypeNotExits(type, masterId);
}
// @Override
// public String getTypeNotExits(List<String> type, String masterId) {
// return archiveDetailRepository.getTypeNotExits(type, masterId);
// }
@Override
public String checkExamApply(String masterId)throws Exception {
return archiveDetailRepository.checkExamApply(masterId);
}
// @Override
// public String checkExamApply(String masterId)throws Exception {
// return archiveDetailRepository.checkExamApply(masterId);
// }
@Override
public String test() {
List<ArchiveDetail> archiveDetails = archiveDetailRepository.findArchiveDetail("肾病内科","2020-04-06 00:00:00");
// FileUtils.haha(archiveDetails);
System.out.println(archiveDetails.size());
int i = 0;
for (ArchiveDetail a : archiveDetails) {
if (a.getPdfPath() != null) {
i = FileUtils.deleteImageFile1(new File(a.getPdfPath()), i);
}
}
System.out.println("一共有:" + archiveDetails.size());
System.out.println("一共删除:" + i);
return null;
}
}

@ -21,6 +21,7 @@ import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* @Author: LeiJiaXin
@ -61,6 +62,7 @@ public class QueueService {
messageSubordinate.setRemark("住院号:" + messageDto.getInpNo() + "pdf路径为空可能出现下载问题。。。");
} else {
ArchiveMaster archiveMaster = archiveMasterService.findByInpNoAndVisitIdAndIsValid(messageDto.getInpNo(), messageDto.getVisitId());
Date date = new Date();
if (archiveMaster != null) {
if (!Objects.equals(messageDto.getType(), AliasName.PATHOLOGY_REPORT)) {
if (archiveMaster.getArchiveState().equals("初审") || archiveMaster.getArchiveState().equals("已归档")) {
@ -71,7 +73,6 @@ public class QueueService {
}
String address = messageDto.getReportAddress();
Date date = new Date();
if (address != null && (!address.equals(""))) {
// 如果是老数据
if (Objects.equals(messageDto.getIsOld(), "0")) {
@ -91,38 +92,49 @@ public class QueueService {
}
String pdfPath = null;
String emrPath = "";
String tempPath = "";
Integer pageNum = 1;
if (messageDto.getSource().equals(InterfaceName.NURSE_DATA)) {
//医生 护理单独做处理
// 护理单独做处理
if (archiveMaster.getEmrNurseCmt() == null) {
archiveMaster.setEmrNurseCmt("提交");
archiveMasterService.save(archiveMaster);
}
String a = "";
String tempPageNum = "";
if (messageDto.getApplyId().lastIndexOf("_") != -1) {
a = messageDto.getApplyId().substring(0, messageDto.getApplyId().indexOf(".pdf"));
//apply_id 000562390700_1_000562390700_0_1_JHR06.00.02_34_2.pdf
tempPageNum = messageDto.getApplyId().substring(0, messageDto.getApplyId().indexOf(".pdf"));
}else{
a = address.substring(0, address.lastIndexOf("_"));
// address ftp://10.6.0.155/2020-08-04/000562390700_1_000562390700_0_1_JHR06.00.02_34_2_0.pdf
tempPageNum = address.substring(0, address.lastIndexOf("_"));
}
tempPageNum = tempPageNum.substring(tempPageNum.lastIndexOf("_") + 1, tempPageNum.length() );
if(isInteger(tempPageNum)){
pageNum = Integer.valueOf(tempPageNum);
}
emrPath = messageDto.getType() + "~" + (a.substring(a.lastIndexOf("_") + 1, a.length())) + "~";
tempPath = messageDto.getType() + "~" + pageNum + "~";
} else if (messageDto.getSource().equals(InterfaceName.DOCTOR_DATA)) {
//护士 护理单独做处理
// 医生单独做处理
if (archiveMaster.getEmrDoctorCmt() == null) {
archiveMaster.setEmrDoctorCmt("提交");
archiveMasterService.save(archiveMaster);
}
emrPath = messageDto.getType() + "~" + messageDto.getCaptionDateTime() + "~";
tempPath = messageDto.getType() + "~" + messageDto.getCaptionDateTime() + "~";
} else {
// 20200518 给重症系统的文件排序
if (messageDto.getType().equals(AliasName.ICU_REPORT)) {
if(isInteger(messageDto.getCaptionDateTime())){
pageNum = Integer.valueOf(messageDto.getCaptionDateTime());
}
//重症如果是pdf
emrPath = messageDto.getDetailType() + "~" + messageDto.getCaptionDateTime() + "~";
tempPath = messageDto.getDetailType() + "~" + messageDto.getCaptionDateTime() + "~";
}
}
File pdfFile = FileUtils.createFile("pdfs", messageDto.getInpNo(), messageDto.getVisitId(), archiveDetail.getId(), emrPath);
File pdfFile = FileUtils.createFile("pdfs", messageDto.getInpNo(), messageDto.getVisitId(), archiveDetail.getId(), tempPath);
if (pdfFile != null) {
if (address.endsWith(".pdf") || address.endsWith(".PDF")) {
String path = DownloadUtils.downLoadPdfFile(pdfFile, address, messageDto.getType());
@ -153,7 +165,7 @@ public class QueueService {
}
} else {
// 一张图片转成pdf
File imageFile = FileUtils.createFile("images", messageDto.getInpNo(), messageDto.getVisitId(), archiveDetail.getId(), emrPath);
File imageFile = FileUtils.createFile("images", messageDto.getInpNo(), messageDto.getVisitId(), archiveDetail.getId(), tempPath);
if (DownloadUtils.downloadImageFile(address, messageDto.getType(), imageFile)) {
pdfPath = PdfUtils.imagesToPdf(imageFile, pdfFile);
}
@ -163,6 +175,7 @@ public class QueueService {
//存入pdf地址
if (pdfPath != null) {
// 转成格式
archiveDetail.setPageNumber(pageNum);
archiveDetail.setPdfPath(pdfPath);
archiveDetailService.save(archiveDetail);
@ -182,27 +195,9 @@ public class QueueService {
archiveDetailService.delete(archiveDetail.getId());
}
}
} else {
// 判断是否是扫描文件
if(messageDto.getType().equals(AliasName.SCANNING_FILE)){
String outContent = this.handlePdfFile(messageDto, archiveMaster.getId());
if(outContent == null){
status = 1;
//更新messageLog的最后执行时间
Date xmlCreateTime = messageLog.getXmlCreateTime();
long beginTime = xmlCreateTime.getTime();
long endTime = date.getTime();
messageLog.setXmlExecutionTime(endTime - beginTime);
messageService.save(messageLog);
}else{
messageSubordinate.setRemark(outContent);
}
} else {
messageSubordinate.setRemark("地址为空。。。。");
}
}
} else{
messageSubordinate.setRemark("住院号为:" + messageDto.getInpNo() + "的ArchiveMaster为空。。。。");
}
@ -241,45 +236,6 @@ public class QueueService {
}
}
public String handlePdfFile(MessageDto messageDto,String masterId) throws Exception {
try {
ScanningFile scanningFile = JSON.parseObject(messageDto.getObject().toString(), ScanningFile.class);
if (scanningFile == null) {
return "扫描文件解析实体错误。。。";
}
Object[] objects = WebServiceUtils.connect(scanningFile.getPath() + "\\" + scanningFile.getFileName());
if (objects == null) {
return "扫描文件下载图片出错了。。。";
}
byte[] bytes = (byte[]) objects[0];
String path = (scanningFile.getApplyId() != null ? scanningFile.getApplyId() : "") + "~" + (scanningFile.getNumber() != null ? scanningFile.getNumber() : "");
// 给临时图片填充内容
File imageTempFile = FileUtils.createFile("images", messageDto.getInpNo(), messageDto.getVisitId(), path);
File imageFile = FileUtils.getImageFileByByteArray(bytes, imageTempFile);
if (imageFile == null) {
return "扫描文件填充临时图片出错了。。。";
}
File pdfFile = FileUtils.createFile("pdfs", messageDto.getInpNo(), messageDto.getVisitId(), path);
String pdfPath = PdfUtils.imagesToPdf(imageFile, pdfFile);
//存入pdf地址
if (pdfPath == null) {
return "扫描文件image转成pdf出错了。。。";
}
// 如果存在 那就更新
ArchiveDetail archiveDetail = archiveDetailService.isExit(masterId, messageDto.getType(), messageDto.getSource(), messageDto.getApplyId() + "~" + (scanningFile.getNumber() != null ? scanningFile.getNumber() : ""));
if (archiveDetail == null) {
archiveDetail = new ArchiveDetail(masterId, new Date(), messageDto.getType(), messageDto.getSource(), messageDto.getApplyId() + "~" + (scanningFile.getNumber() != null ? scanningFile.getNumber() : ""), pdfPath);
archiveDetailService.save(archiveDetail);
}
} catch (Exception e) {
return e + "";
}
return null;
}
public void doSomethingByHIS() {
try {
@ -302,10 +258,10 @@ public class QueueService {
}
// 查询库中是否存在 如果存在就更新
archiveDetail = archiveDetailService.isExit(archiveMaster.getId(), interfaceHisCache.getType(), "HIS系统", "");
archiveDetail = archiveDetailService.isExit(archiveMaster.getId(), type, "HIS系统", title);
Date date = new Date();
if (archiveDetail == null) {
archiveDetail = new ArchiveDetail(archiveMaster.getId(), date, type, "HIS系统", "",
archiveDetail = new ArchiveDetail(archiveMaster.getId(), date, type, "HIS系统", title,
title ,1);
archiveDetailService.save(archiveDetail);
}else{
@ -359,4 +315,9 @@ public class QueueService {
}
}
public boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
}

@ -1,23 +0,0 @@
package com.ann.utils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @Description
* @Date 2019/6/24 10:51
* @Created by ljx
*/
public class DateUtils {
// 生成指定格式的时间
public static String getDateStr() {
//日期转换为字符串
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
return now.format(format);
}
}

@ -227,9 +227,9 @@ public class DownloadUtils {
userName = "his";
password = "his_docus";
}else if(Objects.equals(type, AliasName.OTHER_REPORT)) {
//其他报告 根据IP区分报告类型 考虑IP单独做配置
userName = "";
password = "";
// 2020-8-18 后续接入的报告 统一走ftp、固定账号密码common/common
userName = "common";
password = "common";
}else {
// 电子病历
// ftp://10.6.0.155/2020-01-25/000593857900_1_000593857900_0_4_EMR06.02.04_3_5_0.pdf

@ -149,7 +149,6 @@ public class FTPUtil {
// 切换FTP目录
ftpClient.changeWorkingDirectory("/");
int dele = ftpClient.dele(path);
System.out.println(dele);
logger.error("删除FTP文件为{}",address);
flag = true;
} catch (Exception e) {

@ -27,61 +27,36 @@ public class FileUtils {
// pdf地址
public static String pdfPath;
public static File createFile(String fileType, String inpNo, String visitId, String path) throws Exception {
File localFile = null;
try {
//生成图片地址
// ---------------------------此处写死 年月需改善
LocalDate date = LocalDate.now();
String fileDirName = null;
if (Objects.equals(fileType, "images")) {
fileDirName = "Z:/images/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
} else if (Objects.equals(fileType, "pdfs")) {
fileDirName = pdfPath + "/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
}
//判断是否有该文件夹 否则创建
File fileDir = new File(fileDirName);
if (!fileDir.exists()) {
fileDir.mkdirs();
@Value("${file.pdfPath}")
public void setPdfPath(String pdfPath) {
FileUtils.pdfPath = pdfPath;
}
String fileName = null;
if (Objects.equals(fileType, "images")) {
fileName = fileDir + "/" + path + ".jpg";
} else if (Objects.equals(fileType, "pdfs")) {
fileName = fileDir + "/" + path + ".pdf";
public static String getPdfPath() {
return pdfPath;
}
localFile = new File(fileName);
if (!localFile.exists()) {
localFile.createNewFile();
}
} catch (IOException e) {
throw e;
}
return localFile;
// pdf地址
public static String imagePath;
@Value("${file.imagePath}")
public void setImagePath(String imagePath) {
FileUtils.imagePath = imagePath;
}
@Value("${file.pdfPath}")
public void setPdfPath(String pdfPath) {
FileUtils.pdfPath = pdfPath;
public static String getImagePath() {
return imagePath;
}
public static String getPdfPath() {
return pdfPath;
}
public static File createFile(String fileType, String inpNo, String visitId, String masterId, String emrPath) throws IOException {
public static File createFile(String fileType, String inpNo, String visitId, String detailId, String tempPath) throws IOException {
File localFile = null;
try {
//生成图片地址
// ---------------------------此处写死 年月需改善
LocalDate date = LocalDate.now();
String fileDirName = null;
if (Objects.equals(fileType, "images")) {
fileDirName = "Z:/images/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
fileDirName = imagePath+"/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
} else if (Objects.equals(fileType, "pdfs")) {
fileDirName = pdfPath + "/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
}
@ -94,9 +69,9 @@ public class FileUtils {
String fileName = null;
if (Objects.equals(fileType, "images")) {
fileName = fileDir + "/" + emrPath + masterId + ".jpg";
fileName = fileDir + "/" + tempPath + detailId + ".jpg";
} else if (Objects.equals(fileType, "pdfs")) {
fileName = fileDir + "/" + emrPath + masterId + ".pdf";
fileName = fileDir + "/" + tempPath + detailId + ".pdf";
}
localFile = new File(fileName);
@ -116,7 +91,7 @@ public class FileUtils {
LocalDate date = LocalDate.now();
String fileDirName = null;
if (Objects.equals(fileType, "images")) {
fileDirName = "Z:/images/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
fileDirName = imagePath+"/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
} else if (Objects.equals(fileType, "pdfs")) {
fileDirName = pdfPath + "/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
}

@ -38,41 +38,5 @@ public class FtpUtils {
return ftp;
}
/* public static boolean downloadFtp(String path, FtpClient ftp, File file) throws IOException, FtpProtocolException {
InputStream is = null;
FileOutputStream fos = null;
boolean result = false;
try {
is = ftp.getFileStream(path);
// is
byte[] bytes = new byte[1024];
int i;
fos = new FileOutputStream(file);
while((i = is.read(bytes)) != -1){
fos.write(bytes, 0, i);
}
result = true;
} catch (Exception e) {
FileUtils.deleteImageFile(file);
logger.error("出错咯!错误信息:"+e);
throw e;
} finally {
try {
if(fos!=null) {
fos.close();
}
if(is!=null){
is.close();
}
} catch (IOException e) {
FileUtils.deleteImageFile(file);
logger.error("出错咯!错误信息:"+e);
throw e;
}
}
return result;
}*/
}

@ -70,60 +70,6 @@ public class JSchUtils {
}
}
/**
* ,
*
*
* @throws JSchException
*/
public static void execCmd(String command) throws JSchException {
BufferedReader reader = null;
try {
if (command != null) {
channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// ((ChannelExec) channel).setErrStream(System.err);
channel.connect();
InputStream in = channel.getInputStream();
reader = new BufferedReader(new InputStreamReader(in));
String buf = null;
while ((buf = reader.readLine()) != null) {
logger.info(buf);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (JSchException e) {
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
channel.disconnect();
}
}
/**
*
*
* @param directory
* @param uploadFile
* @throws JSchException
* @throws SftpException
* @throws FileNotFoundException
*/
public static void upload(String directory, String uploadFile) throws Exception {
ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
channelSftp.cd(directory);
File file = new File(uploadFile);
channelSftp.put(new FileInputStream(file), file.getName());
logger.info("上传: " + uploadFile + "成功!");
}
/**
*
*
@ -142,19 +88,6 @@ public class JSchUtils {
}
/**
*
*
* @param directory
* @return
* @throws SftpException
* @throws JSchException
*/
@SuppressWarnings("rawtypes")
public Vector listFiles(String directory) throws Exception {
ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
return channelSftp.ls(directory);
}
public static void main(String[] args) {
try {

@ -1,224 +0,0 @@
package com.ann.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Vector;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.jcraft.jsch.*;
import org.apache.commons.io.IOUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @Author: LeiJiaXin
* @Date: 2019/9/2 11:19
*/
public class SFTPUtil {
private transient Logger log = LoggerFactory.getLogger(this.getClass());
private ChannelSftp sftp;
private Session session;
/**
* SFTP
*/
private String username;
/**
* SFTP
*/
private String password;
/**
*
*/
private String privateKey;
/**
* SFTP IP
*/
private String host;
/**
* SFTP
*/
private int port;
/**
* sftp
*/
public SFTPUtil(String username, String password, String host, int port) {
this.username = username;
this.password = password;
this.host = host;
this.port = port;
}
/**
* sftp
*/
public SFTPUtil(String username, String host, int port, String privateKey) {
this.username = username;
this.host = host;
this.port = port;
this.privateKey = privateKey;
}
public SFTPUtil() {
}
/**
* sftp
*/
public void login() {
try {
JSch jsch = new JSch();
if (privateKey != null) {
jsch.addIdentity(privateKey);// 设置私钥
}
session = jsch.getSession(username, host, port);
if (password != null) {
session.setPassword(password);
}
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
sftp = (ChannelSftp) channel;
} catch (JSchException e) {
e.printStackTrace();
}
}
/**
* server
*/
public void logout() {
if (sftp != null) {
if (sftp.isConnected()) {
sftp.disconnect();
}
}
if (session != null) {
if (session.isConnected()) {
session.disconnect();
}
}
}
/**
* sftp=basePath+directory
*
* @param basePath
* @param directory
* @param sftpFileName sftp
*/
public void upload(String basePath, String directory, String sftpFileName, InputStream input) throws SftpException {
try {
sftp.cd(basePath);
sftp.cd(directory);
} catch (SftpException e) {
//目录不存在,则创建文件夹
String[] dirs = directory.split("/");
String tempPath = basePath;
for (String dir : dirs) {
if (null == dir || "".equals(dir)) continue;
tempPath += "/" + dir;
try {
sftp.cd(tempPath);
} catch (SftpException ex) {
sftp.mkdir(tempPath);
sftp.cd(tempPath);
}
}
}
sftp.put(input, sftpFileName); //上传文件
}
/**
*
*
* @param directory
* @param downloadFile
* @param saveFile
*/
public void download(String directory, String downloadFile, File saveFile) throws SftpException, FileNotFoundException {
if (directory != null && !"".equals(directory)) {
sftp.cd(directory);
}
sftp.get(downloadFile, new FileOutputStream(saveFile));
}
/**
*
*
* @param directory
* @param downloadFile
* @return
*/
public byte[] download(String directory, String downloadFile) throws SftpException, IOException {
if (directory != null && !"".equals(directory)) {
sftp.cd(directory);
}
InputStream is = sftp.get(downloadFile);
byte[] fileData = IOUtils.toByteArray(is);
return fileData;
}
/**
*
*
* @param directory
* @param deleteFile
*/
public void delete(String directory, String deleteFile) throws SftpException {
sftp.cd(directory);
sftp.rm(deleteFile);
}
/**
*
*
* @param directory
*/
public Vector<?> listFiles(String directory) throws SftpException {
return sftp.ls(directory);
}
//上传文件测试
public static void main(String[] args) throws SftpException, IOException {
SFTPUtil sftp = new SFTPUtil("用户名", "密码", "ip地址", 22);
sftp.login();
File file = new File("D:\\图片\\t0124dd095ceb042322.jpg");
InputStream is = new FileInputStream(file);
sftp.upload("基础路径", "文件路径", "test_sftp.jpg", is);
sftp.logout();
}
}

@ -50,7 +50,8 @@ file:
dischargeRecordPath: D:\\1\dischargeRecord.properties
transferRecordPath: D:\\1\transferRecord.properties
admissionRecordPath: D:\\1\admissionRecord.properties
pdfPath: D:/project_js
pdfPath: Z:/project_js
imagePath: Z:/images
signContent: <REQUEST>
<patient_statu>0</patient_statu>

Loading…
Cancel
Save