FeiYongJieShouChongSuan.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package thyyxxk.webserver.scheduled;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.scheduling.annotation.Scheduled;
  5. import org.springframework.stereotype.Component;
  6. import thyyxxk.webserver.dao.his.scheduled.JieShouFeiYongDao;
  7. import thyyxxk.webserver.entity.yibao.patient.Patient;
  8. import thyyxxk.webserver.service.PublicServer;
  9. import thyyxxk.webserver.service.yibao.PatientService;
  10. import java.util.List;
  11. /**
  12. * <p>
  13. * 描述: 费用接受重算
  14. * </p>
  15. *
  16. * @author xc
  17. * @date 2021-12-21 16:37
  18. */
  19. @Slf4j
  20. @Component
  21. public class FeiYongJieShouChongSuan {
  22. private final JieShouFeiYongDao dao;
  23. private final PatientService patientService;
  24. private final PublicServer publicServer;
  25. @Value("${execute-scheduled}")
  26. private Boolean executeScheduled;
  27. public FeiYongJieShouChongSuan(JieShouFeiYongDao dao, PatientService patientService, PublicServer publicServer) {
  28. this.dao = dao;
  29. this.patientService = patientService;
  30. this.publicServer = publicServer;
  31. }
  32. @Scheduled(cron = "0 30 23 * * ?")
  33. public void jieShouFeiYong() {
  34. // 每天 23 点 执行
  35. if (executeScheduled) {
  36. List<Patient> xuYaoJieShouDeFeiYong = dao.xuYaoJieShouFeiYong();
  37. for (Patient item : xuYaoJieShouDeFeiYong) {
  38. try {
  39. if (item.getLedgerSn() == null) {
  40. item.setLedgerSn(publicServer.getLedgerSn(item.getInpatientNo(), item.getAdmissTimes()));
  41. }
  42. patientService.receiveAndRecalculateCost(item);
  43. } catch (Exception e) {
  44. log.info("费用接受失败==>住院号:{},住院次数:{},账页号:{}", item.getInpatientNo(), item.getAdmissTimes(), item.getLedgerSn());
  45. e.printStackTrace();
  46. }
  47. }
  48. }
  49. }
  50. @Scheduled(cron = "59 59 23 * * ?")
  51. public void chongZhiYaoDanHao() {
  52. if (executeScheduled) {
  53. dao.chongZhiYaoDanHao();
  54. }
  55. }
  56. }