package org.jeecg; import org.jeecg.modules.medical.entity.AfterwardsAudit; import org.jeecg.modules.medical.entity.AfterwardsAuditDetail; import org.jeecg.modules.medical.job.AfterWaringLogTestJob; import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService; import org.jeecg.modules.medical.service.IAfterwardsAuditService; import org.junit.Test; import org.junit.runner.RunWith; import org.quartz.JobExecutionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.*; /** * @author soft01 * @time 2023/5/28 21:41 * @description '生成一些模拟数据' * @parentProject medical-java */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class) public class AfterwardsAuditDataTest { List> doctorList = new ArrayList<>(); //就诊类别;住院(hosp)/门诊(outpatient) public static final String TREATMENTTYPE = "hops"; public static final String NOTICE_TYPE = "after"; public static final String medicalDeptCode = "1001"; //部门代码 public static final String deptName = "儿科"; //科室 // public static final String doctorName = "章邯"; // public static final String doctorId = "1001001"; // 患者信息 public static final String patientId = "A1001"; public static final String patientName = "魏冉"; public static final String ZYH = "H001"; // 住院号 // 医嘱/处方号 public static final String prescriptionNumber = "P001"; // 项目类型 medicine;consumable;diagnoses; public static final String PROJECTTYPE = "medicine"; public static final String PROJECTCODE = "8001"; @Autowired private IAfterwardsAuditService afterwardsAuditService; @Autowired private IAfterwardsAuditDetailService afterwardsAuditDetailService; @Autowired private AfterWaringLogTestJob afterWaringLogTestJob; @Test public void testJob(){ try { afterWaringLogTestJob.execute(null); } catch (JobExecutionException e) { e.printStackTrace(); } } @Test public void generateAfterwardsAuditData() { Map doctorItem1 = new HashMap<>(); doctorItem1.put("doctorName", "章邯"); doctorItem1.put("doctorId", "1001001"); Map doctorItem2 = new HashMap<>(); doctorItem2.put("doctorName", "楚南公"); doctorItem2.put("doctorId", "1001006"); Map doctorItem3 = new HashMap<>(); doctorItem3.put("doctorName", "晓梦"); doctorItem3.put("doctorId", "1001005"); Map doctorItem4 = new HashMap<>(); doctorItem4.put("doctorName", "柳梦璃"); doctorItem4.put("doctorId", "1002002"); Map doctorItem5 = new HashMap<>(); doctorItem5.put("doctorName", "司马懿"); doctorItem5.put("doctorId", "1001201"); Map doctorItem6 = new HashMap<>(); doctorItem6.put("doctorName", "荀彧"); doctorItem6.put("doctorId", "1001202"); Map doctorItem7 = new HashMap<>(); doctorItem7.put("doctorName", "夏侯渊"); doctorItem7.put("doctorId", "1001203"); Map doctorItem8 = new HashMap<>(); doctorItem8.put("doctorName", "曹仁"); doctorItem8.put("doctorId", "1001205"); Map doctorItem9 = new HashMap<>(); doctorItem9.put("doctorName", "孙权"); doctorItem9.put("doctorId", "1001206"); Map doctorItem10 = new HashMap<>(); doctorItem10.put("doctorName", "鲁肃"); doctorItem10.put("doctorId", "1001207"); doctorList.add(doctorItem1); doctorList.add(doctorItem2); doctorList.add(doctorItem3); doctorList.add(doctorItem4); doctorList.add(doctorItem5); doctorList.add(doctorItem6); doctorList.add(doctorItem7); doctorList.add(doctorItem8); doctorList.add(doctorItem9); doctorList.add(doctorItem10); for (Map stringStringMap : doctorList) { String doctorName = stringStringMap.get("doctorName"); String doctorId = stringStringMap.get("doctorId"); // 写主表 AfterwardsAudit extracted = writeMaster(doctorId, doctorName); // 写从表 writeSlave(doctorId, doctorName, extracted.getId(), 5); } } private void writeSlave(String doctorId, String doctorName, Integer id, int number) { for (int i = 0; i < number; i++) { AfterwardsAuditDetail aad = new AfterwardsAuditDetail(); aad.setAfterwardsAuditId(id); aad.setMedicalInsRuleInfoId(1); aad.setMedicalInsRuleInfoCode("1"); aad.setMedicalInsRuleInfoName("前"); aad.setTreatmentType(TREATMENTTYPE); aad.setReminderLevel("1"); aad.setViolationLevel(1); aad.setNoticeType(NOTICE_TYPE); aad.setMedicalDeptCode(medicalDeptCode); aad.setMedicalDeptName(deptName); aad.setDoctorName(doctorName); aad.setDoctorId(doctorId); aad.setPatientId(patientId); aad.setPatientName(patientName); aad.setOutpatientNumber(aad.getOutpatientNumber()); aad.setPrescriptionNumber(prescriptionNumber); aad.setProjectType(PROJECTTYPE); aad.setProejctCode(PROJECTCODE); aad.setQuantity(new BigDecimal("1")); aad.setMedicalProjectCode("8001"); aad.setMedicalProjectName("1"); aad.setAmount(BigDecimal.valueOf(AfterwardsAuditDataTest.getRandom())); aad.setCreateBy("admin"); aad.setCreateTime(new Date()); afterwardsAuditDetailService.save(aad); } } AfterwardsAudit writeMaster(String doctorId, String doctorName) { AfterwardsAudit aa = new AfterwardsAudit(); aa.setTreatmentType(TREATMENTTYPE); aa.setNoticeType(NOTICE_TYPE); aa.setMedicalDeptCode(medicalDeptCode); aa.setMedicalDeptName(deptName); aa.setDoctorName(doctorName); aa.setDoctorId(doctorId); aa.setPatientId(patientId); aa.setPatientName(patientName); aa.setOutpatientNumber(ZYH); aa.setPrescriptionNumber(prescriptionNumber); aa.setFeedbackResult("SUCCESS"); aa.setFeedbackCode("0000"); aa.setAuditSource("system(系统)"); aa.setCreateBy("admin"); aa.setCreateTime(new Date()); afterwardsAuditService.save(aa); return aa; } public static void main(String[] args) { getRandom(); } private static double getRandom() { Random a = new Random(); int i = a.nextInt(200) - 80; double v = a.nextDouble(); System.out.println(i + v); return i + v; } }