AfterwardsAuditDataTest.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. package org.jeecg;
  2. import org.jeecg.modules.medical.entity.AfterwardsAudit;
  3. import org.jeecg.modules.medical.entity.AfterwardsAuditDetail;
  4. import org.jeecg.modules.medical.job.AfterWaringLogTestJob;
  5. import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService;
  6. import org.jeecg.modules.medical.service.IAfterwardsAuditService;
  7. import org.junit.Test;
  8. import org.junit.runner.RunWith;
  9. import org.quartz.JobExecutionException;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.boot.test.context.SpringBootTest;
  12. import org.springframework.test.context.junit4.SpringRunner;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import java.math.BigDecimal;
  15. import java.util.*;
  16. /**
  17. * @author soft01
  18. * @time 2023/5/28 21:41
  19. * @description '生成一些模拟数据'
  20. * @parentProject medical-java
  21. */
  22. @RunWith(SpringRunner.class)
  23. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
  24. public class AfterwardsAuditDataTest {
  25. List<Map<String, String>> doctorList = new ArrayList<>();
  26. //就诊类别;住院(hosp)/门诊(outpatient)
  27. public static final String TREATMENTTYPE = "hops";
  28. public static final String NOTICE_TYPE = "after";
  29. public static final String medicalDeptCode = "1001"; //部门代码
  30. public static final String deptName = "儿科"; //科室
  31. // public static final String doctorName = "章邯";
  32. // public static final String doctorId = "1001001";
  33. // 患者信息
  34. public static final String patientId = "A1001";
  35. public static final String patientName = "魏冉";
  36. public static final String ZYH = "H001"; // 住院号
  37. // 医嘱/处方号
  38. public static final String prescriptionNumber = "P001";
  39. // 项目类型 medicine;consumable;diagnoses;
  40. public static final String PROJECTTYPE = "medicine";
  41. public static final String PROJECTCODE = "8001";
  42. @Autowired
  43. private IAfterwardsAuditService afterwardsAuditService;
  44. @Autowired
  45. private IAfterwardsAuditDetailService afterwardsAuditDetailService;
  46. @Autowired
  47. private AfterWaringLogTestJob afterWaringLogTestJob;
  48. @Test
  49. public void testJob(){
  50. try {
  51. afterWaringLogTestJob.execute(null);
  52. } catch (JobExecutionException e) {
  53. e.printStackTrace();
  54. }
  55. }
  56. @Test
  57. public void generateAfterwardsAuditData() {
  58. Map<String, String> doctorItem1 = new HashMap<>();
  59. doctorItem1.put("doctorName", "章邯");
  60. doctorItem1.put("doctorId", "1001001");
  61. Map<String, String> doctorItem2 = new HashMap<>();
  62. doctorItem2.put("doctorName", "楚南公");
  63. doctorItem2.put("doctorId", "1001006");
  64. Map<String, String> doctorItem3 = new HashMap<>();
  65. doctorItem3.put("doctorName", "晓梦");
  66. doctorItem3.put("doctorId", "1001005");
  67. Map<String, String> doctorItem4 = new HashMap<>();
  68. doctorItem4.put("doctorName", "柳梦璃");
  69. doctorItem4.put("doctorId", "1002002");
  70. Map<String, String> doctorItem5 = new HashMap<>();
  71. doctorItem5.put("doctorName", "司马懿");
  72. doctorItem5.put("doctorId", "1001201");
  73. Map<String, String> doctorItem6 = new HashMap<>();
  74. doctorItem6.put("doctorName", "荀彧");
  75. doctorItem6.put("doctorId", "1001202");
  76. Map<String, String> doctorItem7 = new HashMap<>();
  77. doctorItem7.put("doctorName", "夏侯渊");
  78. doctorItem7.put("doctorId", "1001203");
  79. Map<String, String> doctorItem8 = new HashMap<>();
  80. doctorItem8.put("doctorName", "曹仁");
  81. doctorItem8.put("doctorId", "1001205");
  82. Map<String, String> doctorItem9 = new HashMap<>();
  83. doctorItem9.put("doctorName", "孙权");
  84. doctorItem9.put("doctorId", "1001206");
  85. Map<String, String> doctorItem10 = new HashMap<>();
  86. doctorItem10.put("doctorName", "鲁肃");
  87. doctorItem10.put("doctorId", "1001207");
  88. doctorList.add(doctorItem1);
  89. doctorList.add(doctorItem2);
  90. doctorList.add(doctorItem3);
  91. doctorList.add(doctorItem4);
  92. doctorList.add(doctorItem5);
  93. doctorList.add(doctorItem6);
  94. doctorList.add(doctorItem7);
  95. doctorList.add(doctorItem8);
  96. doctorList.add(doctorItem9);
  97. doctorList.add(doctorItem10);
  98. for (Map<String, String> stringStringMap : doctorList) {
  99. String doctorName = stringStringMap.get("doctorName");
  100. String doctorId = stringStringMap.get("doctorId");
  101. // 写主表
  102. AfterwardsAudit extracted = writeMaster(doctorId, doctorName);
  103. // 写从表
  104. writeSlave(doctorId, doctorName, extracted.getId(), 5);
  105. }
  106. }
  107. private void writeSlave(String doctorId, String doctorName, Integer id, int number) {
  108. for (int i = 0; i < number; i++) {
  109. AfterwardsAuditDetail aad = new AfterwardsAuditDetail();
  110. aad.setAfterwardsAuditId(id);
  111. aad.setMedicalInsRuleInfoId(1);
  112. aad.setMedicalInsRuleInfoCode("1");
  113. aad.setMedicalInsRuleInfoName("前");
  114. aad.setTreatmentType(TREATMENTTYPE);
  115. aad.setReminderLevel("1");
  116. aad.setViolationLevel(1);
  117. aad.setNoticeType(NOTICE_TYPE);
  118. aad.setMedicalDeptCode(medicalDeptCode);
  119. aad.setMedicalDeptName(deptName);
  120. aad.setDoctorName(doctorName);
  121. aad.setDoctorId(doctorId);
  122. aad.setPatientId(patientId);
  123. aad.setPatientName(patientName);
  124. aad.setOutpatientNumber(aad.getOutpatientNumber());
  125. aad.setPrescriptionNumber(prescriptionNumber);
  126. aad.setProjectType(PROJECTTYPE);
  127. aad.setProejctCode(PROJECTCODE);
  128. aad.setQuantity(new BigDecimal("1"));
  129. aad.setMedicalProjectCode("8001");
  130. aad.setMedicalProjectName("1");
  131. aad.setAmount(BigDecimal.valueOf(AfterwardsAuditDataTest.getRandom()));
  132. aad.setCreateBy("admin");
  133. aad.setCreateTime(new Date());
  134. afterwardsAuditDetailService.save(aad);
  135. }
  136. }
  137. AfterwardsAudit writeMaster(String doctorId, String doctorName) {
  138. AfterwardsAudit aa = new AfterwardsAudit();
  139. aa.setTreatmentType(TREATMENTTYPE);
  140. aa.setNoticeType(NOTICE_TYPE);
  141. aa.setMedicalDeptCode(medicalDeptCode);
  142. aa.setMedicalDeptName(deptName);
  143. aa.setDoctorName(doctorName);
  144. aa.setDoctorId(doctorId);
  145. aa.setPatientId(patientId);
  146. aa.setPatientName(patientName);
  147. aa.setOutpatientNumber(ZYH);
  148. aa.setPrescriptionNumber(prescriptionNumber);
  149. aa.setFeedbackResult("SUCCESS");
  150. aa.setFeedbackCode("0000");
  151. aa.setAuditSource("system(系统)");
  152. aa.setCreateBy("admin");
  153. aa.setCreateTime(new Date());
  154. afterwardsAuditService.save(aa);
  155. return aa;
  156. }
  157. public static void main(String[] args) {
  158. getRandom();
  159. }
  160. private static double getRandom() {
  161. Random a = new Random();
  162. int i = a.nextInt(200) - 80;
  163. double v = a.nextDouble();
  164. System.out.println(i + v);
  165. return i + v;
  166. }
  167. }