123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package thyyxxk.webserver.scheduled;
- import lombok.extern.slf4j.Slf4j;
- import org.aspectj.lang.annotation.Pointcut;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import thyyxxk.webserver.dao.his.scheduled.JieShouFeiYongDao;
- import thyyxxk.webserver.entity.inpatient.patient.Patient;
- import thyyxxk.webserver.service.PublicServer;
- import thyyxxk.webserver.service.inpatient.PatientService;
- import javax.annotation.PostConstruct;
- import javax.validation.constraints.Positive;
- import java.util.List;
- /**
- * <p>
- * 描述: 费用接受重算
- * </p>
- *
- * @author xc
- * @date 2021-12-21 16:37
- */
- @Slf4j
- @Component
- public class FeiYongJieShouChongSuan {
- private final JieShouFeiYongDao dao;
- private final PatientService patientService;
- private final PublicServer publicServer;
- @Value("${execute-scheduled}")
- private Boolean executeScheduled;
- public FeiYongJieShouChongSuan(JieShouFeiYongDao dao, PatientService patientService, PublicServer publicServer) {
- this.dao = dao;
- this.patientService = patientService;
- this.publicServer = publicServer;
- }
- /**
- * 费用接受重算
- */
- @Scheduled(cron = "0 30 23 * * ?")
- public void jieShouFeiYong() {
- // 每天 23 点 执行
- if (executeScheduled) {
- List<Patient> xuYaoJieShouDeFeiYong = dao.xuYaoJieShouFeiYong();
- for (Patient item : xuYaoJieShouDeFeiYong) {
- try {
- if (item.getLedgerSn() == null) {
- item.setLedgerSn(publicServer.getLedgerSn(item.getInpatientNo(), item.getAdmissTimes()));
- }
- patientService.receiveAndRecalculateCost(item);
- log.info("费用接受成功==>住院号:{},住院次数:{},账页号:{} ", item.getInpatientNo(), item.getAdmissTimes(), item.getLedgerSn());
- } catch (Exception e) {
- log.info("费用接受失败==>住院号:{},住院次数:{},账页号:{},错误信息:{}", item.getInpatientNo(), item.getAdmissTimes(), item.getLedgerSn(), getExceptionAllinformation(e));
- e.printStackTrace();
- }
- }
- }
- }
- public static String getExceptionAllinformation(Exception ex) {
- StringBuilder sOut = new StringBuilder();
- StackTraceElement[] trace = ex.getStackTrace();
- for (StackTraceElement s : trace) {
- sOut.append("\tat ").append(s).append("\r\n");
- }
- return sOut.toString();
- }
- @Scheduled(cron = "59 59 23 * * ?")
- public void chongZhiYaoDanHao() {
- if (executeScheduled) {
- dao.chongZhiYaoDanHao();
- }
- }
- }
|