parent
ca9b5ed6ee
commit
1e494017b7
@ -1,16 +0,0 @@
|
||||
package com.ann.demo.entity.constant;
|
||||
|
||||
|
||||
/**
|
||||
* @Description 操作
|
||||
* @Date 2019/6/13 16:39
|
||||
* @Created by ljx
|
||||
*/
|
||||
public class Identification {
|
||||
|
||||
public static final String INSERT = "insert";
|
||||
|
||||
public static final String UPDATE = "update";
|
||||
|
||||
public static final String DELETE = "delete";
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.ann.demo.entity.constant;
|
||||
|
||||
/**
|
||||
* @Description 除了HL7V3的xml 返回参数
|
||||
* @Date 2019/6/13 21:50
|
||||
* @Created by ljx
|
||||
*/
|
||||
public class OutParaConstant {
|
||||
|
||||
public static final boolean RESULT_CODE_SUCCESS = true;
|
||||
public static final boolean RESULT_CODE_FILED = false;
|
||||
|
||||
public static final String RESULT_CONTENT_SUCCESS = "成功";
|
||||
public static final String RESULT_CONTENT_FILED = "失败";
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.ann.demo.entity.interfaceEntity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 输血单
|
||||
*
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/22 15:42
|
||||
*/
|
||||
@Data
|
||||
public class BloodApply {
|
||||
|
||||
private Date xmlCreateTime;
|
||||
|
||||
private String inpNo;
|
||||
|
||||
private String visitId;
|
||||
|
||||
private String patientId;
|
||||
|
||||
private String reportAddress;
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.ann.demo.entity.interfaceEntity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/10 10:04
|
||||
*/
|
||||
@Data
|
||||
public class EMRData {
|
||||
// 2019-9-28 新增id
|
||||
private String applyId;
|
||||
|
||||
private Date xmlCreateTime;
|
||||
|
||||
private String inpNo;
|
||||
|
||||
private String visitId;
|
||||
|
||||
private String patientId;
|
||||
|
||||
// 病历文书
|
||||
private String type;
|
||||
|
||||
private String reportAddress;
|
||||
|
||||
private String lastModifyTime;
|
||||
|
||||
private String commitTime;
|
||||
|
||||
// 知情同意
|
||||
private String subType;
|
||||
|
||||
// 知情同意下面的类型
|
||||
private String detailType;
|
||||
|
||||
//排序的时间
|
||||
private String captionDateTime;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.ann.demo.entity.interfaceEntity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 检验申请单
|
||||
*
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/12/23 15:42
|
||||
*/
|
||||
@Data
|
||||
public class InspectionApply {
|
||||
|
||||
private String applyId;
|
||||
|
||||
private Date xmlCreateTime;
|
||||
|
||||
private String inpNo;
|
||||
|
||||
private String visitId;
|
||||
|
||||
private String patientId;
|
||||
|
||||
private Date authorReportTime;
|
||||
|
||||
private String result;
|
||||
|
||||
private Integer isValid = 0;
|
||||
|
||||
/**
|
||||
* 2019-10-21 新增是否开立接口 E 检查 F 取消检查
|
||||
*/
|
||||
private String isOpen;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.ann.demo.entity.interfaceEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description 医嘱
|
||||
* @Date 2020/7/1 9:00
|
||||
* @Created by ljx
|
||||
*/
|
||||
|
||||
@Table
|
||||
@Entity
|
||||
@Data
|
||||
public class InterfaceHisCache {
|
||||
|
||||
@Id
|
||||
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
||||
@GeneratedValue(generator = "system-uuid")
|
||||
private String id;
|
||||
|
||||
private String inpNo;
|
||||
|
||||
private String visitId;
|
||||
|
||||
// 医嘱类型 0代表临时医嘱 1代表长期医嘱
|
||||
private String type;
|
||||
|
||||
private String pdfPath;
|
||||
|
||||
private String remark;
|
||||
|
||||
// 0代表未处理 1代表已处理 2代表处理异常 3代表召回作废
|
||||
private String state = "0";
|
||||
|
||||
//2020-7-6 新增修改时间
|
||||
private Date updateTime = new Date();
|
||||
|
||||
|
||||
public InterfaceHisCache(String inpNo, String visitId, String type) {
|
||||
this.inpNo = inpNo;
|
||||
this.visitId = visitId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setValue(String state, String remark, Date updateTime) {
|
||||
this.state = state;
|
||||
this.remark = remark;
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public InterfaceHisCache() {
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.CommonTable1;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/6 15:49
|
||||
*/
|
||||
@Repository
|
||||
public interface CommonTable1Repository extends JpaRepository<CommonTable1, String> {
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.CommonTable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/6 15:49
|
||||
*/
|
||||
@Repository
|
||||
public interface CommonTableRepository extends JpaRepository<CommonTable, String> {
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.Department;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/7/16 9:53
|
||||
*/
|
||||
@Repository
|
||||
public interface DepartmentRepository extends JpaRepository<Department, String> {
|
||||
|
||||
@Query("select o from Department o where o.DEPT_CODE = ?1 and o.isValid = ?2 ")
|
||||
public Department findDepartmentByDeptCodeAndIsValid(String deptCode, Integer isValid);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.DiagDetail;
|
||||
import com.ann.demo.entity.normalEntity.ids.DiagDetailIds;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/6 15:49
|
||||
*/
|
||||
@Repository
|
||||
public interface DiagDetailRepository extends JpaRepository<DiagDetail, DiagDetailIds> {
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.EMRDictionary;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/21 16:04
|
||||
*/
|
||||
@Repository
|
||||
public interface EMRDictionaryRepository extends JpaRepository<EMRDictionary, Integer> {
|
||||
|
||||
@Query("select o from EMRDictionary o where o.DEPT_CODE = ?1 and o.isValid = ?2 ")
|
||||
public EMRDictionary findEMRDictionaryByCodeAndIsValid(String code, Integer isValid);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.interfaceEntity.ExamApply;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/22 16:22
|
||||
*/
|
||||
@Repository
|
||||
public interface ExamApplyRepository extends JpaRepository<ExamApply, String> {
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update ExamApply o set o.isValid = 1 where o.applyId = ?1 and o.isValid = 0 ")
|
||||
public Integer updateExamApplyIsValidById(String applyId);
|
||||
|
||||
@Query("select count(o) from ExamApply o where o.applyId = ?1 and o.isValid = 0")
|
||||
public Integer countExamApply(String applyId);
|
||||
|
||||
public ExamApply findByApplyId(String applyId);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.interfaceEntity.InterfaceHisCache;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
public interface InterfaceHisCacheRepository extends JpaRepository<InterfaceHisCache,String> {
|
||||
|
||||
public List<InterfaceHisCache> findAllByStateAndPdfPathIsNotNull(String state);
|
||||
|
||||
public InterfaceHisCache findByInpNoAndVisitIdAndStateAndType(String inpNo,String visitId,String state,String type);
|
||||
|
||||
|
||||
@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(String state, String id, String type);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.MedicalRecordHomepageCache;
|
||||
import com.ann.demo.entity.normalEntity.ids.MedicalRecordHomepageCacheIds;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/26 9:31
|
||||
*/
|
||||
@Repository
|
||||
public interface MedicalRecordHomepageCacheRepository extends JpaRepository<MedicalRecordHomepageCache, MedicalRecordHomepageCacheIds> {
|
||||
|
||||
public MedicalRecordHomepageCache findByMasterId(String masterId);
|
||||
|
||||
@Modifying
|
||||
@Query("update MedicalRecordHomepageCache m set m.isAdd = 1 where m.masterId = ?1 and m.isAdd = 0")
|
||||
public void updateIsValid(String masterId);
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.OperDetail;
|
||||
import com.ann.demo.entity.normalEntity.ids.OperDetailIds;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/6 15:49
|
||||
*/
|
||||
@Repository
|
||||
public interface OperDetailRepository extends JpaRepository<OperDetail, OperDetailIds> {
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.ann.demo.repository;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/7/16 9:53
|
||||
*/
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, String> {
|
||||
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.Department;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Date 2019/7/16 9:56
|
||||
* @Created by ljx
|
||||
*/
|
||||
|
||||
public interface DepartmentService {
|
||||
|
||||
public void save(Department department);
|
||||
|
||||
public void delete(Department department);
|
||||
|
||||
public Department findDepartment(String user_dept);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.EMRDictionary;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/21 16:08
|
||||
*/
|
||||
public interface EMRDictionaryService {
|
||||
|
||||
public void save(EMRDictionary emrDictionary);
|
||||
|
||||
public void delete(EMRDictionary emrDictionary);
|
||||
|
||||
public EMRDictionary findEMRDictionary(String code);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
import com.ann.demo.entity.interfaceEntity.ExamApply;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/22 16:20
|
||||
*/
|
||||
public interface ExamApplyService {
|
||||
|
||||
public void save(ExamApply examApply);
|
||||
|
||||
/* public boolean updateExamApplyIsValidById(String id);*/
|
||||
|
||||
//public String findId(String applyId,String inpNo,String visitId,String patientId);
|
||||
|
||||
public ExamApply findExamApply(String applyId);
|
||||
|
||||
Integer countExamApply(String applyId);
|
||||
|
||||
boolean updateExamApplyIsValid(String applyId);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
|
||||
|
||||
import com.ann.demo.entity.interfaceEntity.InterfaceHisCache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface InterfaceHisCacheService {
|
||||
|
||||
//查询所有未处理的状态
|
||||
public List<InterfaceHisCache> findInterfaceHisCacheByState();
|
||||
|
||||
//修改状态
|
||||
public boolean updateState(String state, String id, String type);
|
||||
|
||||
void save(InterfaceHisCache interfaceHisCache);
|
||||
|
||||
InterfaceHisCache findInterfaceHisCache(String inpNo, String visitId, String type);
|
||||
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.MedicalRecordHomepage;
|
||||
import com.ann.demo.entity.normalEntity.MedicalRecordHomepageCache;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/26 9:26
|
||||
*/
|
||||
public interface MedicalRecordHomepageCacheService {
|
||||
|
||||
public boolean save(String masterId) throws Exception;
|
||||
|
||||
public boolean save(MedicalRecordHomepageCache m) throws Exception;
|
||||
|
||||
void delete(String masterId) throws Exception;
|
||||
|
||||
public MedicalRecordHomepageCache handleMedicalRecordHomepageCache(MedicalRecordHomepage medicalRecordHomepage) throws Exception;
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.MedicalRecordHomepage;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/6 15:46
|
||||
*/
|
||||
public interface MedicalRecordHomepageService {
|
||||
|
||||
|
||||
public boolean save(MedicalRecordHomepage medicalRecordHomepage);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.ann.demo.service;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.User;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Date 2019/7/16 9:56
|
||||
* @Created by ljx
|
||||
*/
|
||||
|
||||
public interface UserService {
|
||||
|
||||
public void save(User user);
|
||||
|
||||
public void delete(User user);
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.Department;
|
||||
import com.ann.demo.repository.DepartmentRepository;
|
||||
import com.ann.demo.service.DepartmentService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Date 2019/7/9 16:43
|
||||
* @Created by ljx
|
||||
*/
|
||||
@Service
|
||||
public class DepartmentServiceImpl implements DepartmentService {
|
||||
|
||||
static final Logger logger = LoggerFactory.getLogger(DepartmentServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
@Override
|
||||
public void save(Department department) {
|
||||
//打日志信息
|
||||
try {
|
||||
departmentRepository.save(department);
|
||||
} catch (Exception e) {
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Department department) {
|
||||
//打日志信息
|
||||
try {
|
||||
departmentRepository.delete(department);
|
||||
} catch (Exception e) {
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Department findDepartment(String user_dept) {
|
||||
// ------------------确认 isValid 0是正常 1是停用
|
||||
return departmentRepository.findDepartmentByDeptCodeAndIsValid(user_dept, 0);
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.EMRDictionary;
|
||||
import com.ann.demo.repository.EMRDictionaryRepository;
|
||||
import com.ann.demo.service.EMRDictionaryService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/21 16:08
|
||||
*/
|
||||
@Service
|
||||
public class EMRDictionaryServiceImpl implements EMRDictionaryService {
|
||||
|
||||
static final Logger logger = LoggerFactory.getLogger(EMRDictionaryServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
EMRDictionaryRepository emrDictionaryRepository;
|
||||
|
||||
@Override
|
||||
public void save(EMRDictionary emrDictionary) {
|
||||
//打日志信息
|
||||
try {
|
||||
emrDictionaryRepository.save(emrDictionary);
|
||||
} catch (Exception e) {
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(EMRDictionary emrDictionary) {
|
||||
//打日志信息
|
||||
try {
|
||||
emrDictionaryRepository.delete(emrDictionary);
|
||||
} catch (Exception e) {
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EMRDictionary findEMRDictionary(String code) {
|
||||
// ------------------确认 isValid 0是正常 1是停用
|
||||
return emrDictionaryRepository.findEMRDictionaryByCodeAndIsValid(code, 0);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.ann.demo.entity.interfaceEntity.ExamApply;
|
||||
import com.ann.demo.repository.ExamApplyRepository;
|
||||
import com.ann.demo.service.ExamApplyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/22 16:20
|
||||
*/
|
||||
@Service
|
||||
public class ExamApplyServiceImpl implements ExamApplyService {
|
||||
|
||||
@Autowired
|
||||
ExamApplyRepository examApplyRepository;
|
||||
|
||||
@Override
|
||||
public void save(ExamApply examApply) {
|
||||
examApplyRepository.save(examApply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExamApply findExamApply(String applyId) {
|
||||
return examApplyRepository.findByApplyId(applyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countExamApply(String applyId) {
|
||||
return examApplyRepository.countExamApply(applyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateExamApplyIsValid(String applyId) {
|
||||
if (examApplyRepository.updateExamApplyIsValidById(applyId) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.ann.demo.entity.interfaceEntity.InterfaceHisCache;
|
||||
import com.ann.demo.repository.InterfaceHisCacheRepository;
|
||||
import com.ann.demo.service.InterfaceHisCacheService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class InterfaceHisCacheServiceImpl implements InterfaceHisCacheService {
|
||||
|
||||
@Autowired
|
||||
private InterfaceHisCacheRepository interfaceHisCacheRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public List<InterfaceHisCache> findInterfaceHisCacheByState() {
|
||||
return interfaceHisCacheRepository.findAllByStateAndPdfPathIsNotNull("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateState(String state,String id,String type ) {
|
||||
if(interfaceHisCacheRepository.updateStateById(state,id,type) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(InterfaceHisCache interfaceHisCache) {
|
||||
interfaceHisCacheRepository.save(interfaceHisCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterfaceHisCache findInterfaceHisCache(String inpNo, String visitId, String type) {
|
||||
return interfaceHisCacheRepository.findByInpNoAndVisitIdAndStateAndType(inpNo,visitId,"0",type);
|
||||
}
|
||||
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ann.demo.entity.interfaceEntity.ArchiveMaster;
|
||||
import com.ann.demo.entity.normalEntity.*;
|
||||
import com.ann.demo.repository.MedicalRecordHomepageCacheRepository;
|
||||
import com.ann.demo.service.ArchiveMasterService;
|
||||
import com.ann.demo.service.MedicalRecordHomepageCacheService;
|
||||
import com.ann.demo.service.MedicalRecordHomepageService;
|
||||
import com.ann.demo.utils.PinYinUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**l
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/9/26 9:27
|
||||
*/
|
||||
@Service
|
||||
public class MedicalRecordHomepageCacheServiceImpl implements MedicalRecordHomepageCacheService {
|
||||
|
||||
static final Logger logger = LoggerFactory.getLogger(MedicalRecordHomepageCacheServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
MedicalRecordHomepageCacheRepository medicalRecordHomepageCacheRepository;
|
||||
|
||||
@Autowired
|
||||
MedicalRecordHomepageService medicalRecordHomepageService;
|
||||
|
||||
@Autowired
|
||||
ArchiveMasterService archiveMasterService;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean save(String masterId) throws Exception{
|
||||
MedicalRecordHomepageCache medicalRecordHomepageCache = medicalRecordHomepageCacheRepository.findByMasterId(masterId);
|
||||
if (medicalRecordHomepageCache != null) {
|
||||
MedicalRecordHomepage m = JSON.parseObject(medicalRecordHomepageCache.getContent(), MedicalRecordHomepage.class);
|
||||
if (medicalRecordHomepageService.save(m)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(MedicalRecordHomepageCache medicalRecordHomepageCache) throws Exception{
|
||||
try {
|
||||
MedicalRecordHomepageCache mrh = medicalRecordHomepageCacheRepository.findByMasterId(medicalRecordHomepageCache.getMasterId());
|
||||
if (mrh != null) {
|
||||
medicalRecordHomepageCache.setRemark("已更新");
|
||||
}
|
||||
medicalRecordHomepageCacheRepository.save(medicalRecordHomepageCache);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(String masterId) throws Exception{
|
||||
medicalRecordHomepageCacheRepository.updateIsValid(masterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MedicalRecordHomepageCache handleMedicalRecordHomepageCache(MedicalRecordHomepage medicalRecordHomepage) throws Exception{
|
||||
// 查询主键 姓名简写 是否手术 是否过敏药物
|
||||
String masterId = null;
|
||||
MedicalRecordHomepageCache medicalRecordHomepageCache = null;
|
||||
CommonTable commonTable = medicalRecordHomepage.getCommonTable();
|
||||
if (commonTable != null) {
|
||||
if (commonTable.getYZY002() != null && commonTable.getYZY001() != null) {
|
||||
ArchiveMaster archiveMaster = archiveMasterService.findByPatientIdAndVisitIdAndIsValid(commonTable.getYZY001(), commonTable.getYZY002());
|
||||
if (archiveMaster != null) {
|
||||
masterId = archiveMaster.getId();
|
||||
if (masterId != null) {
|
||||
List<OperDetail> operDetails = medicalRecordHomepage.getOperDetails();
|
||||
List<DiagDetail> diagDetails = medicalRecordHomepage.getDiagDetails();
|
||||
CommonTable1 commonTable1 = medicalRecordHomepage.getCommonTable1();
|
||||
|
||||
if (commonTable1 != null) {
|
||||
// 处理公共表
|
||||
commonTable.setMasterId(masterId);
|
||||
// 将 患者id 赋值给 病案号
|
||||
commonTable.setInpatient_no(commonTable.getYZY001());
|
||||
if (operDetails != null) {
|
||||
if (operDetails.size() > 0) {
|
||||
commonTable.setIsOper("有");
|
||||
} else {
|
||||
commonTable.setIsOper("没有");
|
||||
}
|
||||
} else {
|
||||
commonTable.setIsOper("没有");
|
||||
}
|
||||
if (commonTable.getAAC003() != null) {
|
||||
commonTable.setNameCym(PinYinUtils.getPingYin(commonTable.getAAC003()));
|
||||
}
|
||||
String akc023 = commonTable.getAKC023();
|
||||
if (akc023 != null) {
|
||||
if (akc023.indexOf("岁") != -1) {
|
||||
commonTable.setAge(Integer.parseInt(akc023.substring(0, akc023.indexOf("岁"))));
|
||||
} else if (akc023.indexOf("月") != -1 && akc023.indexOf("岁") == -1) {
|
||||
commonTable.setAge_month(Integer.parseInt(akc023.substring(0, akc023.indexOf("月"))));
|
||||
} else if (akc023.indexOf("天") != -1 && akc023.indexOf("岁") == -1 && akc023.indexOf("月") == -1) {
|
||||
commonTable.setAge_day(Integer.parseInt(akc023.substring(0, akc023.indexOf("天"))));
|
||||
}
|
||||
}
|
||||
|
||||
// 处理公共表1
|
||||
if (commonTable1.getYZY046() != null) {
|
||||
commonTable1.setIs_medicine("是");
|
||||
} else {
|
||||
commonTable1.setIs_medicine("否");
|
||||
}
|
||||
commonTable1.setMasterId(masterId);
|
||||
|
||||
|
||||
// 保存手术表
|
||||
if (operDetails != null) {
|
||||
for (OperDetail operDetail : operDetails) {
|
||||
operDetail.setMasterId(masterId);
|
||||
}
|
||||
}
|
||||
// 诊断表
|
||||
if (diagDetails != null) {
|
||||
for (DiagDetail diagDetail : diagDetails) {
|
||||
diagDetail.setMasterId(masterId);
|
||||
// 20200528 取出院诊断的主要诊断
|
||||
if(Objects.equals(diagDetail.getYZY203(),"3") && Objects.equals(diagDetail.getYZY201(),1) ){
|
||||
medicalRecordHomepage.getOtherData().setMainDiagCode(diagDetail.getAKC196());
|
||||
commonTable.setMainDiagName(diagDetail.getAKC185());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
medicalRecordHomepage.setCommonTable(commonTable);
|
||||
medicalRecordHomepage.setCommonTable1(commonTable1);
|
||||
medicalRecordHomepage.setDiagDetails(diagDetails);
|
||||
medicalRecordHomepage.setOperDetails(operDetails);
|
||||
|
||||
medicalRecordHomepageCache = new MedicalRecordHomepageCache(masterId, JSON.toJSONString(medicalRecordHomepage));
|
||||
return medicalRecordHomepageCache;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.*;
|
||||
import com.ann.demo.repository.*;
|
||||
import com.ann.demo.service.MedicalRecordHomepageService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/6 15:46
|
||||
*/
|
||||
@Service
|
||||
public class MedicalRecordHomepageServiceImpl implements MedicalRecordHomepageService {
|
||||
|
||||
static final Logger logger = LoggerFactory.getLogger(MedicalRecordHomepageServiceImpl.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
DiagDetailRepository diagDetailRepository;
|
||||
|
||||
@Autowired
|
||||
CommonTable1Repository commonTable1Repository;
|
||||
|
||||
@Autowired
|
||||
CommonTableRepository commonTableRepository;
|
||||
|
||||
@Autowired
|
||||
OperDetailRepository operDetailRepository;
|
||||
|
||||
@Autowired
|
||||
ArchiveMasterRepository archiveMasterRepository;
|
||||
|
||||
public boolean save(MedicalRecordHomepage medicalRecordHomepage) {
|
||||
// 查询主键 姓名简写 是否手术 是否过敏药物
|
||||
String masterId = medicalRecordHomepage.getCommonTable().getMasterId();
|
||||
try {
|
||||
List<OperDetail> operDetails = medicalRecordHomepage.getOperDetails();
|
||||
List<DiagDetail> diagDetails = medicalRecordHomepage.getDiagDetails();
|
||||
// 保存手术表
|
||||
if (operDetails != null) {
|
||||
for (OperDetail operDetail : operDetails) {
|
||||
operDetail.setMasterId(masterId);
|
||||
operDetailRepository.save(operDetail);
|
||||
}
|
||||
}
|
||||
// 诊断表
|
||||
if (diagDetails != null) {
|
||||
for (DiagDetail diagDetail : diagDetails) {
|
||||
diagDetail.setMasterId(masterId);
|
||||
diagDetailRepository.save(diagDetail);
|
||||
}
|
||||
}
|
||||
// 保存公共表
|
||||
commonTableRepository.save(medicalRecordHomepage.getCommonTable());
|
||||
// 保存公共表 1
|
||||
commonTable1Repository.save(medicalRecordHomepage.getCommonTable1());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error("保存病案首页出错咯!错误信息:" + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package com.ann.demo.service.impl;
|
||||
|
||||
import com.ann.demo.entity.normalEntity.EMRDictionary;
|
||||
import com.ann.demo.entity.normalEntity.User;
|
||||
import com.ann.demo.repository.UserRepository;
|
||||
import com.ann.demo.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Date 2019/7/9 16:43
|
||||
* @Created by ljx
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
EMRDictionaryServiceImpl emrDictionaryService;
|
||||
|
||||
@Override
|
||||
public void save(User user) {
|
||||
//打日志信息
|
||||
try {
|
||||
// 获取科室 根据科室类型区分临床和非临床,临床的然后有资质的就是医生,没有资质的就是护士
|
||||
Integer roleId = 0;
|
||||
if (user.getUSER_DEPT() != null) {
|
||||
EMRDictionary emrDictionary = emrDictionaryService.findEMRDictionary(user.getUSER_DEPT());
|
||||
if (emrDictionary != null) {
|
||||
if (emrDictionary.getCLINIC_ATTR() == 0) {
|
||||
if (user.getEDUCATION_FLAG() == 0) { // 无资质 护士
|
||||
roleId = 1;
|
||||
} else { // 有资质 为 1 医生
|
||||
roleId = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
user.setUSER_TYPE(roleId);
|
||||
userRepository.save(user);
|
||||
} catch (Exception e) {
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(User user) {
|
||||
//打日志信息
|
||||
try {
|
||||
userRepository.delete(user);
|
||||
} catch (Exception e) {
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package com.ann.demo.utils;
|
||||
|
||||
|
||||
import com.ann.demo.entity.normalEntity.MedicalRecordHomepage;
|
||||
import com.ann.demo.entity.normalEntity.OperDetail;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @Description 下载工具
|
||||
* @Date 2019/7/2 16:56
|
||||
* @Created by ljx
|
||||
*/
|
||||
public class DownloadUtils {
|
||||
|
||||
static final Logger logger = LoggerFactory.getLogger(DownloadUtils.class);
|
||||
|
||||
|
||||
/**
|
||||
* 从网络Url中下载文件
|
||||
*
|
||||
* @param urlStr
|
||||
* @param fileName
|
||||
* @param savePath
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void downLoadByUrl(String urlStr, String fileName, String savePath) throws IOException {
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
//设置超时间为5秒
|
||||
conn.setConnectTimeout(5 * 1000);
|
||||
//防止屏蔽程序抓取而返回403错误
|
||||
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
||||
//得到输入流
|
||||
InputStream inputStream = conn.getInputStream();
|
||||
//获取自己数组
|
||||
byte[] getData = readInputStream(inputStream);
|
||||
//文件保存位置
|
||||
File saveDir = new File(savePath);
|
||||
if (!saveDir.exists()) {
|
||||
saveDir.mkdir();
|
||||
}
|
||||
File file = new File(saveDir + File.separator + fileName);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(getData);
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
System.out.println("info:" + url + " download success");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从输入流中获取字节数组
|
||||
*
|
||||
* @param inputStream
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] readInputStream(InputStream inputStream) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
bos.close();
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
//从共享目录下载文件
|
||||
public static boolean cmdFile(String path, File imageFile) {
|
||||
boolean result = false;
|
||||
BufferedInputStream in = null;
|
||||
BufferedOutputStream out = null;
|
||||
try {
|
||||
Runtime.getRuntime().exec("net use \\10.6.0.74 his /user:his");
|
||||
in = new BufferedInputStream(new FileInputStream(path));
|
||||
out = new BufferedOutputStream(new FileOutputStream(imageFile));
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
while (in.read(buffer) != -1) {
|
||||
out.write(buffer);
|
||||
buffer = new byte[1024];
|
||||
}
|
||||
out.flush();
|
||||
result = true;
|
||||
} catch (IOException e) {
|
||||
// FileUtils.deleteImageFile(imageFile);
|
||||
logger.error("出错咯!错误信息:" + e);
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// FileUtils.deleteImageFile(imageFile);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
/* // String file_path = "D:/images/2019/7/25/456.txt";
|
||||
// File file = new File(file_path);
|
||||
try {
|
||||
downLoadByUrl("http://localhost:8080/static/bootstrap/15abd8b4-794a-499a-ab03-abdf14cf331f.pdf","hahaha.pdf","D:/images/");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
Field[] fields = MedicalRecordHomepage.class.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
if (field.getGenericType().toString().equals(OperDetail.class.toString())) {
|
||||
System.out.println(field.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package com.ann.demo.utils;
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 转换拼音
|
||||
*
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/8/7 11:15
|
||||
*/
|
||||
@Component
|
||||
public class PinYinUtils {
|
||||
|
||||
// 拼音路径
|
||||
public static String path;
|
||||
@Value("${file.pinyinPath}")
|
||||
private String pathTemp;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
path = pathTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串中的中文转化为拼音,英文字符不变
|
||||
*
|
||||
* @param inputString 患者姓名
|
||||
* @return
|
||||
*/
|
||||
public static String getPingYin(String inputString) {
|
||||
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
|
||||
defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
|
||||
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
||||
String output = "";
|
||||
try {
|
||||
if (inputString != null && inputString.length() > 0
|
||||
&& !"null".equals(inputString)) {
|
||||
String substring = diffPro(inputString);
|
||||
char[] input = substring.trim().toCharArray();
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
if (Character.toString(input[i]).matches(
|
||||
"[\\u4E00-\\u9FA5]+")) {
|
||||
char temp = PinyinHelper.toHanyuPinyinStringArray(input[i], defaultFormat)[0].charAt(0);
|
||||
output += temp + "";
|
||||
} else {
|
||||
output += Character.toString(input[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (BadHanyuPinyinOutputFormatCombination e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 与pinyin.properties中多音字的姓名对比
|
||||
*
|
||||
* @param inputString 中文姓名
|
||||
* @return 百家姓的拼音读法
|
||||
*/
|
||||
private static String diffPro(String inputString) {
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
InputStream inputStream = new BufferedInputStream(new FileInputStream(new File(path)));
|
||||
properties.load(new InputStreamReader(inputStream, "utf-8"));
|
||||
|
||||
Set keyValue = properties.keySet();
|
||||
for (Iterator it = keyValue.iterator(); it.hasNext(); ) {
|
||||
String key = (String) it.next();
|
||||
|
||||
if (inputString.substring(0, key.length()).equals(key)) {
|
||||
String value = inputString.substring(key.length(), inputString.length());
|
||||
return properties.getProperty(key) + value;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return inputString;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(LocalDateTime.now());
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
package com.ann.demo.utils;
|
||||
|
||||
import com.ann.demo.entity.other.QuartzBean;
|
||||
import org.quartz.*;
|
||||
|
||||
/**
|
||||
* @Author: LeiJiaXin
|
||||
* @Date: 2019/7/13 16:53
|
||||
*/
|
||||
public class QuartzUtils {
|
||||
|
||||
/**
|
||||
* 创建定时任务 定时任务创建之后默认启动状态
|
||||
*
|
||||
* @param scheduler 调度器
|
||||
* @param quartzBean 定时任务信息类
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void createScheduleJob(Scheduler scheduler, QuartzBean quartzBean) {
|
||||
try {
|
||||
//获取到定时任务的执行类 必须是类的绝对路径名称
|
||||
//定时任务类需要是job类的具体实现 QuartzJobBean是job的抽象类。
|
||||
Class<? extends Job> jobClass = (Class<? extends Job>) Class.forName(quartzBean.getJobClass());
|
||||
// 构建定时任务信息
|
||||
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(quartzBean.getJobName()).build();
|
||||
// 设置定时任务执行方式
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzBean.getCronExpression());
|
||||
// 构建触发器trigger
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(quartzBean.getJobName()).withSchedule(scheduleBuilder).build();
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println("定时任务类路径出错:请输入类的绝对路径");
|
||||
} catch (SchedulerException e) {
|
||||
System.out.println("创建定时任务出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务名称暂停定时任务
|
||||
*
|
||||
* @param scheduler 调度器
|
||||
* @param jobName 定时任务名称
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
public static void pauseScheduleJob(Scheduler scheduler, String groupName, String jobName) {
|
||||
JobKey jobKey = JobKey.jobKey(jobName, groupName);
|
||||
try {
|
||||
scheduler.pauseJob(jobKey);
|
||||
} catch (SchedulerException e) {
|
||||
System.out.println("暂停定时任务出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务名称恢复定时任务
|
||||
*
|
||||
* @param scheduler 调度器
|
||||
* @param jobName 定时任务名称
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
public static void resumeScheduleJob(Scheduler scheduler, String groupName, String jobName) {
|
||||
JobKey jobKey = JobKey.jobKey(jobName, groupName);
|
||||
try {
|
||||
scheduler.resumeJob(jobKey);
|
||||
} catch (SchedulerException e) {
|
||||
System.out.println("启动定时任务出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务名称立即运行一次定时任务
|
||||
*
|
||||
* @param scheduler 调度器
|
||||
* @param jobName 定时任务名称
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
public static void runOnce(Scheduler scheduler, String jobName) {
|
||||
JobKey jobKey = JobKey.jobKey(jobName);
|
||||
try {
|
||||
scheduler.triggerJob(jobKey);
|
||||
} catch (SchedulerException e) {
|
||||
System.out.println("运行定时任务出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新定时任务
|
||||
*
|
||||
* @param scheduler 调度器
|
||||
* @param quartzBean 定时任务信息类
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
public static void updateScheduleJob(Scheduler scheduler, QuartzBean quartzBean) {
|
||||
try {
|
||||
//获取到对应任务的触发器
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(quartzBean.getJobName());
|
||||
//设置定时任务执行方式
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzBean.getCronExpression());
|
||||
//重新构建任务的触发器trigger
|
||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
|
||||
//重置对应的job
|
||||
scheduler.rescheduleJob(triggerKey, trigger);
|
||||
} catch (SchedulerException e) {
|
||||
System.out.println("更新定时任务出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据定时任务名称从调度器当中删除定时任务
|
||||
*
|
||||
* @param scheduler 调度器
|
||||
* @param jobName 定时任务名称
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
public static void deleteScheduleJob(Scheduler scheduler, String jobName) {
|
||||
JobKey jobKey = JobKey.jobKey(jobName);
|
||||
try {
|
||||
scheduler.deleteJob(jobKey);
|
||||
} catch (SchedulerException e) {
|
||||
System.out.println("删除定时任务出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue